- Posts Tagged ‘Javascript’

Console.log Shortcut

Here is console.log shortcut which could be useful debugging tool: // usage: log('inside coolFunc',this,arguments); // window.log = function(){ log.history = log.history || []; // store logs to an array for reference log.history.push(arguments); if(this.console){ console.log( ); } }; It is taken from this Paul Irish blog. Though here is… (Continue)

JavaScript: Select All Content of any HTML Element

This post is about selecting HTML content of any Element on the document. I need a way to select all content inside <pre></pre>, so that user can copy all code inside it. (function() { function selectText(element) { var doc = document , text = element , range, selection ; if… (Continue)

jQuery: Update Note

A note when I need to update jQuery library from jQuery version 1.8.3 to latest version (1.10.2). .load event -This method is a shortcut for .on( "load", handler ). .load event deprecated in V 1.8. .live() -For this also use .on() now.   .live() removed in V 1.9 .error() -The error()… (Continue)

Dart Language: Better Alternative to JavaScript

Google has developed Dart Language for Web Development to replace JavaScript. It will replace all bad part of JavaScript and keep good part and add few more features to make developers task easier and web page less prone to error. Of course speed is very important factor for developing dart… (Continue)

Few Newer JavaScript Functions

Here are few newer JavaScript functions: querySelector, querySelectorAll, matchesSelector, and classList. querySelector is for selecting DOM based on CSS selector. It is native to JS. So, it is faster than earlier methods libraries (jQuery) used to give us. Details here. Now, libraries will start adopting it as first choice instead… (Continue)

YUI3 to JQuery Conversion or Opposite

I have written few lines of YUI3 code and I wanted to convert that into jQuery as it is. I have noted down these differences: YUI to jQuery 1. Instead of just 'this' → $(this). Inside JQuery callback function, 'this' refers to DOM object, not a jQuery object. 2.… (Continue)

Table Sorting in JavaScript

Here is code which is an extension of Client-side Table Sorting using JavaScript. This extension add few features to the table sorting code in javaScript. This code does not need to add event handler in HTML code. Using JavaScript itself, hander is getting added. Based on string in column, sorting… (Continue)

YUI3: Accordion Examples

Here is a ready three examples of YUI3 Accordions. Last one is the trimmed version so that you can use your own styles on it. I am presenting simplest code here which is the last one. Working Demo of the Simple Accordion. There you will find link to 2nd example.… (Continue)

YUI3: Convert DOM Object to YUI3 Node and Convert YUI node to DOM element

DOM object to YUI3 Node: Wrap the DOM element in or Y.all() depending on DOM element is single element or a list. Y.Node() and Y.NodeList() is also available. // returns a Y.Node instance node ='span')); // or // node = new Y.Node(document.createElement('span')); // Y.all NodeList method: spans =… (Continue)