crazy jquery problem working with mozilla and not in others
i have this code
$(function() { $('#ans_vote a span').click(function(){alert('working');return false;});});
and this html
<div id="ans_vote">
<a href='#'><span>on开发者_Python百科e</span></a>
</div>
<div id="ans_vote">
<a href='#'><span>two</span></a>
</div>
when click one and two in mozilla its working but when click one in ie its working but when click two its not working
This should be on the front page of SO all the time: your "id" values must be unique within a page.
id
should be unique. Use classes instead!
<script>
$(function(){
$('.ans_vote a span').click(function(){
alert('working');return false;
});
});
</script>
<div class="ans_vote">
<a href='#'><span>one</span></a>
</div>
<div class="ans_vote">
<a href='#'><span>two</span></a>
</div>
i placed your jQuery function into $(document).ready(function() {....}
and it's works in IE(version 8) too. but i recommend to you use unique id's for divs.
精彩评论