How to Get Max Attribute Value in JQuery?
In this profound tutorial, we will learn jquery get max attribute value. let’s discuss about jquery get custom attribute value by class. I would like to show you jquery find max attribute value. step by step explain find maximum value of attribute jquery.
Sometimes, you have a many tag with same class and attribute with value, but you need to find maximal value of attribute from that conman class, In bellow you have same HTML tag:
Now, you require to get max value, i mean you need to 5, because that is big value from other, so you can get maximal value from this way:
<meta name="viewport" content="width=device-width, initial-scale=1">
<li class="test" data-id="3">hi</li>
<li class="test" data-id="5">hey</li>
<li class="test" data-id="1">hello</li>
var max = 0;
var value = parseInt($(this).data('id'));
max = (value > max) ? value : max;
I hope it can help you...
We are Recommending you
- JQuery Radio Button Change Event Example
- JQuery Remove Multiple Values from Array Example
- Calculate Number of Days Between Two Dates in JQuery
- JQuery Get Selected Dropdown Value on Change Event Example
- How to Disable Text Selection using JQuery?
- How to Get Selected Radio Button Value in JQuery?
- JQuery Redirect to Another Page After 5 Seconds Example
- Add Edit Delete Table Row Example using JQuery
- How to Disable Browser Back Button using JQuery?
- How to Remove Duplicate Object from Array in JQuery?
- JQuery Datepicker Example using JQuery UI JS
- How to Convert Line Breaks to br in jQuery ?