Hi Karl: Hate to hijack the thread, but hopefully it's somewhat relevant to the original post.
When I suggested the single quotes around the value 'bar', I was going off of what I saw in the docs at http://docs.jquery.com/Selectors/attributeEquals#attributevalue And the code sample: $("input[name='newsletter']").next().text(" is newsletter"); I still consider myself relatively new to jQuery, so could you clarify about quoting the attribute value? Is it similar to terminating a line with a semi-colon (e.g. optional in JS)? Or is it literal text vs variable value (assuming -bar- here is a variable)? Thanks! Charlie On Thu, Sep 17, 2009 at 9:06 AM, Karl Swedberg <k...@englishrules.com>wrote: > > On Sep 17, 2009, at 5:13 AM, Charlie Griefer wrote: > > Pretty sure you need single quotes around bar. > > alert($("input[name='bar']").val()); > > > No. The single quotes are unnecessary. > > On Thu, Sep 17, 2009 at 1:27 AM, pritisolanki <pritiatw...@gmail.com> > wrote: > >> >> Thanks Ralph. >> >> I tried following >> >> alert($("input[name=bar]").val()); >> >> and rather then showing it's value it alert undefined ??? why? >> > > Where are you including your script tag? If it's in the <head>, are you > wrapping your alert() in $(document).ready? Are you sure you have an input > with name="bar"? > > Try this: > > $(document).ready(function() { > alert( $("input[name=bar]").val() ); > }); > > > --Karl > > ____________ > Karl Swedberg > www.englishrules.com > www.learningjquery.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.