Jquery loop over radio buttons & find lowest price on container div -
could utilize jquery find lowest cost , add together class surrounding , alter 'checked="checked"' proper option?
<div><input type="radio" name="rateid" value="1" checked="checked"/>ups ground - $10.91</div> <div><input type="radio" name="rateid" value="2" />ups 3 day select - $14.34</div> <div><input type="radio" name="rateid" value="3" />ups 2nd day air - $19.22</div> <div><input type="radio" name="rateid" value="4" />ups next day air saver - $36.19</div> <div><input type="radio" name="rateid" value="5" />usps priority mail service - $6.35</div>
yes could, this
$('[name="rateid"]').sort(function(a,b) { homecoming $(a).closest('div').text().split('-').pop().replace(/[^\d.]/g, '' ) - $(b).closest('div').text().split('-').pop().replace(/[^\d.]/g, '' ); }).first() .prop('checked', true) .closest('div') .addclass('someclass'); fiddle
jquery
No comments:
Post a Comment