tags:

views:

12

answers:

1

hi

in a array i have 6 elements with id's such as [100,101,102,100,101,102]

now i want to highlite two similar id's such a way that,

on clicking id=100, it should be highlited and on clicking another id=100 that should be highlited because both ids are same, if not same it should not be highlited

so, how to proceed with this using jquery,

I tried it using nth child selector but i didnt get it right..

A: 

You should clarify some things here. Do you have elements in your HTML markup with the id's in your array ?
If so be aware that this is not valid. Element id's have to be unique.

If you have five elements with the id of foobar for instance, a call to $('#foobar') would always return only one node (the first occurence). You should use classes instead of ids if that is your problem.

jAndy
changing id to class how can i highlite 2 same class, i.e, first on clicking first element with class=100 it should be highlited, and on clicking next element with class=100 it should also be highlited... but for me when i click element with class=100 two elemets are being highlited at same time... only on clicking on respective element it has to be highlited
nirmal