A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Get name of textarea or input using jQuery

You can do this in jQuery:

$("textarea[@name=my_field_name]").val();$("input[@name=my_field_name]").val()

Update, the @ is now deprecated. I remember using VisualjQuery and the filters do not have an @…

$("textarea[name=my_field_name]").val();

Thanks to Simon…

This entry was posted in General and tagged , . Bookmark the permalink.

4 Responses to Get name of textarea or input using jQuery

  1. phpcurious says:

    wow, didn’t know that is possible… thanks for sharing!

  2. Rowena says:

    I am contacting you through this contact form as there was no email address available. We would be interested in purchasing advertising on your blog. Please get back to me using the email address I have entered if you would be interested in discussing this further

  3. Simon says:

    the @ is deprecated now I think. So just use:

    textarea[name=my_field_name]

    etc

  4. jaya says:

    Thank you so much for writting the jquery selector for textarea.
    it helps me in selecting textarea with name

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>