Thanks! That did the trick. Very much appreciated. Roi On Tue, Sep 29, 2009 at 12:09 PM, Charlie Griefer <charlie.grie...@gmail.com > wrote:
> $('p[id=' + myClr + ']').addClass('bold'); > > you need to concatenate the variable in with the literal text so it can be > evaluated. > > > On Tue, Sep 29, 2009 at 10:59 AM, roi <roi.agn...@gmail.com> wrote: > >> >> I am trying to do something that seems very simple, but can not get to >> work! Basically, I want to find an element whose ID equals a certain >> value, as represented by a variable. The variable is derived from a >> dropdown list. Here is my code: >> >> $(document).ready(function(){ >> $("select").change(function() { >> var myClr = $("select").val(); >> >> $("p[id=myClr]").addClass("bold"); //this is the line giving me >> trouble >> }); >> }); >> >> I am wondering if it is legal to use a variable within the filter - if >> I replace it with an actual ID value it works fine, but when I >> substitute the variable name nothing happens. >> >> I am sure I am doing something dumb! Thanks for any suggestions. >> >> Roi >> > > > > -- > Charlie Griefer > http://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success. >