我正在创建一个页面,其中一个jQuery对话框提供了一些输入,然后javascript就会显示它们。这在以下几个方面很好:
但是,它不能在7-11或Firefox 26中工作。
演示: http://bit.ly/1chhvBN
IE 11中的错误:
有什么想法吗?提前谢谢你。
发布于 2013-12-30 19:21:18
不要使用href
属性将事件处理程序绑定到元素。您有jQuery,使用它绑定事件。
<div id="favorites">
<a href="#" class="add">+</a>
</div>
然后,只需:
$('#favorites a').click(function(e){
e.preventDefault();
$( '#dialog' ).dialog({width: 850, height: 300});
});
对addToFavorites
按钮也做同样的操作。
<a href="#" class="addToFavorites button" style="width: 150px;">Add to My Favorites</a>
那就做:
$('.addToFavorites').click(function(e){
e.preventDefault();
addToFavorites();
});
下面是一个演示:http://jsfiddle.net/aRpcL/3/
发布于 2013-12-30 19:18:05
使用onclick而不是href打开对话框。
<a onclick="javascript:$( '#dialog' ).dialog({width: 850, height: 300});" class="add">+</a>
注意:试图避免内联脚本,将JS代码移动到某个函数并调用它。
https://stackoverflow.com/questions/20845695
复制相似问题