Do you see the class added in firebug's HTML view?
On Sat, Feb 7, 2009 at 10:49 PM, gberz3 <gbe...@gmail.com> wrote: > > Ok, this is odd. I can perform a .fadeOut() on the acquired divs, but > the .addClass() method specifically isn't working. Is there anything > in particular that I can check? Specific syntax? Anything? > > Also, thanks for the quick support. > > On Feb 7, 10:33 pm, "Mauricio \(Maujor\) Samy Silva" > <css.mau...@gmail.com> wrote: >> There is nothing wrong with your jQuery code. >> Double check the link to jQuery library and the HTML markup. >> >> Try this example tested here: >> >> <style type="text/css" media="all"> >> .midget {background:red} >> </style> >> >> <script >> src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js"></script> >> >> <script type="text/javascript"> >> $(document).ready(function(){ >> $(".testclass").each(function(){ >> $(this).addClass("midget");}); >> >> }); >> </script> >> ... >> <body> >> <p class="testclass">Some text</p> >> <b class="testclass">Some bold text</b> >> ... >> >> -----Mensagem Original----- >> De: "gberz3" <gbe...@gmail.com> >> Para: "jQuery (English)" <jquery-en@googlegroups.com> >> Enviada em: domingo, 8 de fevereiro de 2009 01:07 >> Assunto: [jQuery] Using selectors successfully...? >> >> >> >> > Will someone please explain to me why the following code fails to >> > execute? I have a simple test page set up and jquery doesn't seem >> > happy with what I'm trying to do. I get no errors, and when I log to >> > console in firebug it shows that it is indeed finding my two objects, >> > however it won't actually perform 'addClass': >> >> > $(document).ready(function() { >> >> > $(".testclass").each(function(){ >> > $(this).addClass("midget"); >> > }); >> > }); >> >> > At first I just figured it was because I wasn't doing an "each", but >> > then after trying each and having it still fail, I was back to square >> > one. Also, is it not possible to select based on tags (e.g. >> > 'div.divclass')? >> >> > Any help would be much appreciated. >> >> > Best!