Find lowest array from attr and do action with jQuery -
<li data-meter='2231'> <img src="http://placehold.it/100x100/"> </li> <li data-meter='0'> <img src="http://placehold.it/100x100/000"> </li> <li data-meter='622'> <img src="http://placehold.it/100x100/000"> </li>
how can use $("li").attr('data-meter');
, find lowest action ?
using min on array john resig
try :
$(document).ready(function(){ // function min value in array array.min = function( array ){ return math.min.apply( math, array ); }; var meter= $('li').map(function() { return $(this).data('meter'); }).get(); // alert minimum value alert("min meter: " + array.min(meter)); // or jquery object $('li[data-meter="'+array.min(meter)+'"]') });
Comments
Post a Comment