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 - How to use Radio Button Change Event?
- 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 on html web page using JQuery & CSS?
- 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?
- Remove Duplicate Objects from Array Jquery Example
- Jquery Datepicker example code with demo using Jquery UI
- How to Convert Line Breaks to br in jQuery ?