Let's see :

$("input[name='name']")

So, what is that exactly ?

   - $() is a method
   - "input[name='name']" is the only argument of $() ; oh my gosh, it's a
   string !

So I guess I can do this : $("input[name='" + "name" + "']") and... My oh my
it still works !
Well, let's try something a little bit more acrobatic :
var field_name = "name";
$("input[name='" + field_name + "']")
Awesome.

Hope it helps.

Michel Belleville


2009/11/3 barbercraig <craigbarbe...@googlemail.com>

>
> Hi Guys,
>
> This is my very first post! so please be kind.... :)
>
> Ok, i am very novice to jQuery. But what i am trying to do is use the
> jQuery
> attribute selector to select an input with a specific name.
>
> I can select an input of name type fine by doing the folowing:
>
>      $("input[name='name']").do something...
>
> But, can i pass a variable into that filter? to search for a variable?
>
> So if i had a variable called 'field_name' containing the text: 'email',
> can
> i do something like this:
>
>     $("input[name='(field_name)']").do something...
>
> So that it in this caseit would find an input with the name 'email'
>
> Sorry if this is a doofus question, just can't find any examples of this
> anywhere
>
> thanks for your help guys,
>
> cheers
>
> Craig
>
> --
> View this message in context:
> http://old.nabble.com/passing-a-variable-through-an-attribute-filter-tp26160102s27240p26160102.html
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.
>
>

Reply via email to