jQuery Data Method

jQuery data method gives you the ability to associate arbitrary data with HTML DOM nodes and JavaScript objects. As of jQuery 1.4.3, you have the ability to use this method on JavaScript objects and call for element modification. jQuery.data() method store arbitrary data associated with the specified element or returns the value that was set. […]

Download a HTML content as pdf using javascript – jsPDF

Using jsPDF library, you can download the div containing graphs, tables, contents as a PDF. This is a HTML5 client-side solution for generating PDFs. Simply include library in your <head>, generate your PDF using the many built-in functions, then create a button to trigger the download. <script type=”text/javascript” src=”http://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js”></script> Create a object: var doc = […]

jQuery toggleClass() Method

The jQuery toggleClass() Method toggles between adding and removing one or more class names from each element in the set of matched elements. Example of jQuery toggleClass: Suppose, we have below HTML: <div class=”myclass”>Your text here.</div> When you apply $( “.myclass” ).toggleClass( “newClass” ), we get the following: <div class=”myclass newClass”>Your text here.</div> Again, if […]