15

How to find the value in the max attribute of input element using Jquery

<input type="number" id="pageNumber" class="toolbarField pageNumber" value="1" size="4" min="1" tabindex="7" max="29">

I tried

$("input[max]").val()

But it didn't help

1

3 Answers 3

21

You can use attr() with id selector to get the value of max attribute.

Live Demo

$('#pageNumber').attr('max');
Sign up to request clarification or add additional context in comments.

2 Comments

Beware that although the API documentation states that they may return a Number, attr('max') and val() seem to return strings when used on a number input type element (jquery-1.12.3).
Yes. So better parseInt() it.
9

Use attr() for find the value of an attribute

Try this

$(".toolbarField").attr("max");

or

$('#pageNumber').attr('max');

Reference:

http://api.jquery.com/attr/

Comments

3
$("input").attr("max");

This gets the value of the attribute

See the jQuery API Document for it: http://api.jquery.com/attr/

Comments

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.