/ Published in: jQuery
mad props to Doug Avery (http://snipplr.com/users/dougunderscorenelson/) and http://javascript.about.com/library/blnumclean.htm (for the regex pattern)
Expand |
Embed | Plain Text
//============================================ // Progress Slider Functionality //============================================ // Mad props to Doug Avery (http://www.google.com/profiles/dougunderscorenelson) $.fn.simplify = function(string){ var new_string = string.replace(/[^\d\.-]/g,""); alert(new_string); return new_string; }; $(".progress-slider").addClass("sliderized"); $("li.goal").each(function(){ var count = $(this).find(".count").html(); var target = $(this).find(".target").html(); var processed_count = $(this).simplify(count); var processed_target = $(this).simplify(target); var percent = (processed_count/processed_target)*100; $(this).find(".heading").after('<div class="container-slider"><div class="slider" style="background-position:'+percent+'% 0;"></div></div>'); }); <!-- Here's a bit of example (X)HTML to go with this: <div> <h2>Project Progress</h2> <ul> <li> <h3>Our Membership Status</h3> <p><strong>150</strong> members so far towards our goal of <strong>500</strong></p> </li> <li> <h3>Our Fundraising Status</h3> <p><strong>$200</strong> raised so far towards our goal of <strong>$50,000</strong></p> </li> </ul> </div> -->
You need to login to post a comment.
