tags:

views:

111

answers:

3

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>one</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

+5  A: 

This should be on the front page of SO all the time: your "id" values must be unique within a page.

Pointy
That is why it is called **ID** : Identifier which uniquely identifies an element. +1
Felix Kling
+1  A: 

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.

loviji
+3  A: 

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>   
N 1.1