以下代码行之间有什么区别,或者它们只是两种不同的方式来编写相同的东西:
$("p").click(function() { some code here });
$("p").bind("click", function(){ some other code here });
Run Code Online (Sandbox Code Playgroud)
我是在简化这个吗?因为如果你想绑定多个事件,你可以链接事件,对吗?
这个.show和.hide在Firefox 3中很有用,但在IE 7中不行.当我在IE中的列表中单击<时,跨度隐藏但当我再次选择Between时不再显示.
难道我做错了什么?
<select id="lst" onchange="onselectchange();">
<option>Between</option>
<option><</option>
</select>
<span id="spanAnd">And</span>
<script type="text/javascript">
function onselectchange() {
var lst = document.getElementById('lst');
var sp = document.getElementById('spanAnd');
if (lst.value == 'Between') {
$('#spanAnd').show();
}
else {
$('#spanAnd').hide();
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
编辑:我试过onclick和onchange.