<DIV class='wump1' id=SB1>aaaa</DIV>
<DIV class='wump1' id=SB1>bbb</DIV>
<DIV class='wump1' id=SB1>ccc</DIV>
<DIV class='wump1' id=SB1>ddd</DIV>


I think what you're missing is that HTML doesn't allow for multiple elements with the same id. You should try running your page through a validation tool such as the one at http://validator.w3.org/ and try to fix errors in the markup first.

Using $('#myId'), jQuery will only select the first element in the DOM with that id, since there is only supposed to be one.

Hope that helps.


--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Aug 10, 2007, at 10:56 AM, Andy Matthews wrote:


Have any code you could show us?

I'm betting you need to look into the "each" method of jQuery.

andy

-----Original Message-----
From: [email protected] [mailto:jquery- [EMAIL PROTECTED] On
Behalf Of JJ
Sent: Thursday, August 09, 2007 11:24 AM
To: jQuery (English)
Subject: [jQuery] Am I missing something dumb?


I am a newbie (and very much a convert) to JQuery but have spent all
afternoon bashing my head against a brick wall with this one.

I want to show hide (or in the example, change the class) of a single
element in an array of DIV's).

Whatever I do, I can only reference the first one, and the others seem to be
ignored (even though they appear to resolve to objects).

I have narrowed my code down into a near little example. I am using version
1.1.3.1


Cheers in advance.


JJ



<SCRIPT language=javascript src="jquery.js"></SCRIPT> <style> .selected {
font: 12px Arial, Helvetica, sans-serif;
color: #FF0000;
}
</style>


<DIV class='wump1' id=SB1>aaaa</DIV>
<DIV class='wump1' id=SB1>bbb</DIV>
<DIV class='wump1' id=SB1>ccc</DIV>
<DIV class='wump1' id=SB1>ddd</DIV>

<script>
$(document).ready(function()
{

        $("#SB1:nth(1)").addClass("selected")
        $("#SB1:nth(0)").addClass("selected")

})
</script>



Reply via email to