by matt | May 25, 2016 | Javascript / Jquery
Here is a simple example and explanation of finding and replacing a html element using jquery syntax: $(selector).replaceWith(content,function(index)) simple example: $("div.replacehere").replaceWith("The new content"); replace all divs assosiated with the class...
by matt | Dec 15, 2014 | Javascript / Jquery, Uncategorized
$("#menu-item-999 > a").attr("href", "http://www.newaddres.com");
by matt | Oct 1, 2014 | Javascript / Jquery, Uncategorized
// check if element exists if($('selector').length){ //do something } // check if element does not exist if(!$('selector').length){ //do something }
by matt | Sep 26, 2014 | Javascript / Jquery, Uncategorized
HTML: 1111 2222 3333 4444 5555 jQuery snippet: var swapElements = function(siblings, subjectIndex, objectIndex) { var subject = $(siblings.get(subjectIndex)); var object = siblings.get(objectIndex); subject.insertBefore(object); } $(function() {...
by matt | Sep 26, 2014 | Javascript / Jquery, Uncategorized
In order to move the last element of the first position within the container we can use prepend jQuery command. Please see the following examples : first item will go to the end second item .... the last item $('ul.list-container').prepend($('ul.list-container...
by matt | Sep 25, 2014 | Javascript / Jquery, Uncategorized
Wrap your jquery code with the following: if (!sessionStorage.alreadyShown) { .... yourFunctionOrCodeHere(); .... sessionStorage.alreadyShown = "true"; }