Tutorial by Examples

The jQuery function (usually aliased as $) can be used both to select elements and to create new elements. var myLink = $('<a href="http://stackexchange.com"></a>'); You can optionally pass a second argument with element attributes: var myLink = $('<a>', { 'href': 'h...
Assuming the page includes an HTML element like: <p class="small-paragraph"> This is a small <a href="https://en.wikipedia.org/wiki/Paragraph">paragraph</a> with a <a class="trusted" href="http://stackexchange.com">link</a>...
jQuery offers a variety of methods that can be used for DOM manipulation. The first is the .empty() method. Imagine the following markup: <div id="content"> <div>Some text</div> </div> By calling $('#content').empty();, the inner div would be removed. This...
You can use this method to replace all of the HTML within the selector. Assuming you have an html element like this <div class="row"> <div class="col-md-12"> <div id="information"> <p>Old message</p> &l...
To sort elements efficiently (all at once and with minimal DOM interruption), we need to: Find the elements Sort based on a set condition Insert back in the DOM <ul id='my-color-list'> <li class="disabled">Red</li> <li>Green</li> <li ...

Page 1 of 1