onlinecode

How to get max attribute value in jquery?

How to get max attribute value in jquery?

In this post we will give you information about How to get max attribute value in jquery?. Hear we will give you detail about How to get max attribute value in jquery?And how to use it also give you demo for it if it is necessary.

Sometimes, you have a many tag with same class and attribute with value, but you need to find maximal value of attribute from that comman class, In bellow you have same html tag:

<ul>

<li data-id="3">hi</li>

<li data-id="5">hey</li>

<li data-id="1">hello</li>

</ul>

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:

var max = 0;

$('.test').each(function() {

var value = parseInt($(this).data('id'));

max = (value > max) ? value : max;

});

alert(max);

Hope this code and post will helped you for implement How to get max attribute value in jquery?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version