My musings while programming in a number of languages and libraries, from PHP, Perl, JavaScript, jQuery, and KnockoutJS, with liberal use of CSS and Bootstrap to make it all pretty.
2015-02-27
jQuery: Counting the number of matching class elements on the page
While working on a project I hacked some code together to count the number of flagged questions in an exam. My initial code, which is bad and poorly optimized as seen here:
While here I have my optimized code:
Not only is the optimized code smaller (nearly half as many lines and its also much easier to read.
Labels:
JavaScript,
jQuery
Location:
Milwaukee, WI, USA
Subscribe to:
Posts (Atom)