Category Archives: Code Snippets

9 Javascripts snippets that can make your coding life easy…

This set of 9 javascript snippets are must have JS scripts which can help you in creating clean websites & web apps. You would have used these scripts in many ways as part of developing websites… #1 : A Single … Continue reading

Snippet – jQuery: 6 Snippets to manipulate Select inputs

Interesting set of snippets to manipulate select inputs using jQuery. 1. Get value of the selected option. Simple one line query to get the selected option value… $(‘#selectList’).val(); 2. Get text of the selected option. Similar to snippet:#1, while #1 … Continue reading

Snippet – Prototype: Object extending

Simple snippet to learn object extending in Prototype.. Object.extend = function(object, extend){ for(propety in extend)object[propety]=extend[propety]; }; /* Example */ Object.extend(String.prototype, { camelCase : function(){return this.replace(/-(.)/gi,function(a1,a2){return a2.toUpperCase();});}, share : function(a1){var ret=[];for(var x=0;x<this.length;x+=a1){ret.push(this.slice(x,x+a1));};return ret;} });

Snippet – jQuery: Get content from another page

Learn to get content from another page & display them using jQuery <script type="text/javascript"> var content = $.ajax({ url: "default.html", async: false }).responseText; //set the value of the content into a textarea by creating a textarea & setting the content … Continue reading

Snippet – jQuery: Trim strings using jQuery

Learn to trim strings using jQuery… Function: Trim <script type="text/javascript"> var v = $.trim(" There are extra spaces before and after this sentence. "); alert(v); </script>