Block all body evets except one

<html> <body class=”someClass”> <a href=”thanks.html”>test</a> <a href=”thanks.html” class=”clickable”>test</a> </body> </html> <script src=””></script> <script src=””></script> <script type=”text/javascript”> $(‘body’).click(function(e) { //with jquery if($(‘clickable’)){ return; } e.preventDefault(); return; }); </script> PURE JS <html> <body class=”someClass” onclick=pp(event)> <a href=”thanks.html”>test</a> <a href=”thanks.html” class=”clickable”>test</a> </body> </html>…

Remove Characters One By One (Closure Example)

<html> <body class=”someClass”> <input type=”button” onclick=”pp()” value=”click me”> <input type=”text” id=”jj” value=”Prashant”> </body> </html> <script src=””></script> <script src=””></script> <script type=”text/javascript”> var pp=(function(){ var name=$(“#jj”).val(); var stringlength=name.length; return function(){ var newString=”; for(i=0;i<stringlength;i++){ newString=newString+name[i]; } stringlength–; $(“#jj”).val(newString); } })(); </script>

Create Date Object

<script type=”text/javascript”> function toDate(dateStr) { var parts = dateStr.split(“-“); return new Date(parts[2], parts[1] – 1, parts[0]); } var dateObj=toDate(“23-02-2017”); var dateObj2=toDate(“1-2-2017”); alert(dateObj); alert(dateObj2); </script>

Javascript Prototype

Every JavaScript object has a prototype. The prototype is also an object. All JavaScript objects inherit their properties and methods from their prototype. JavaScript Prototypes All JavaScript objects inherit the properties and methods from their prototype. Objects created using an…

Insertion Sort

insertion sort is one of the fastest algorithms for sorting very small arrays, even faster than quicksort. Performance: Worst case: O(n2) Average case: O(n2) Best case: O(n) <?php function insertionSort(array $array) { $length=count($array); for ($i=1;$i<$length;$i++) { $element=$array[$i]; //put second element…

Page 2 of 712345...Last »