9

I have this input:

<tr><td class="forms">Price:</td><td><input type="text" name="price" size="30"/></td></tr>

How can I call this input?

Example: With this code I call to the id:

$("#numberclasses").change(function() {

And I call to the class with this:

$(".numberclasses").change(function() {

But How can I call to the name?

3
  • what is numberclasses here? Commented Jan 21, 2013 at 17:37
  • 2
    @ryadavilli does it matter? Commented Jan 21, 2013 at 17:39
  • 1
    possible duplicate of How can I select an element by name with JQuery? Commented Jan 22, 2013 at 0:15

1 Answer 1

17

Use:

$('input[name="price"]').change(function() {

Check out the jQuery selectors docs for more info.

Sign up to request clarification or add additional context in comments.

7 Comments

missing quotes? input[name="price"]
This is true, however the docs show with the quotes in the format jQuery( "[attribute='value']" ) so I suppose it's best to follow suit
@TomWalters I did not say to follow W3Schools!! ;D just talking from experience. Kidding, Sure, let's follow the DOCS. always.
@roXon I rarely use the quotes myself, but the jQuery docs are so new and shiny its hard to disagree with them!
@TomWalters HAHAHAHAHAHAHAHAHAH TOM ! you made my day! +10 to your answer! I almost killed my self with my coffee
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.