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 = […]

Difference between event.preventDefault() and return false

preventDefault() prevents the default event from occuring, stopPropagation() prevents the event from bubbling up and return false does the both. Example of preventDefault() and return false: $(‘a’).click(function() { return false; }); $(‘a’).click(function(e) { e.preventDefault(); }); So finally, return false from within a jQuery event handler is effectively same as calling both e.preventDefault and e.stopPropagation on […]

Traversing Siblings

The jQuery  siblings() method returns all the sibling elements of the selected element. For example: $(“div”).siblings(); But if you want to filter the search for siblings then you can use an optional parameter. $(“div”).siblings(“p”); Read Also: Select an element with multiple classes in jQuery jQuery clone – create a deep copy of matched elements Suppose […]

JSON with Ajax

Ajax is Asynchronous JavaScript and XML for for asynchronous web applications. Using ajax data from a server asynchronously retrieved and display without reloading the page. So JSON with Ajax is no exception. JSON stands for JavaScript Object Notation. So, in simple terms JSON is a way of formatting the data. For, e.g., transmitting it over […]