Jquery target input named in last div of class

I have multiple divs with .agrRow class . Each .agrRow has an input field named agrNameOF .

I want to set the value of this field. I've tried something like:

$(".agrRow:last input[type='input'][name='agrNameOF']").val(fname);

      

but it doesn't work.

What is the correct syntax?

+3


source to share


2 answers


try changing input[type='input']

to input[type='text']

or if it could be other types, just doinput[name='agrNameOF']



JSFiddle: http://jsfiddle.net/6tf6fbcn/

+3


source


Try:

$('.agrRow input[type="text"][name="agrNameOF"]').val(fname);

      



why are you using: last?

+1


source







All Articles