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 ?

http://jsfiddle.net/4pmzh/

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)+'"]') }); 

docs .data() , working example


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -