Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery replace h1 with h2

$(selector).load(url, function(){ // your existing load function
      $(selector).find('h1').replaceWith(function() {
                return '<h2>' + $(this).text() + '</h2>';
      });
});
Comment

convert h2 to h1 jQuery

/***
   Changes an HTML elements HTML tag from one type to another
   @ Params:
   elemSelector - the css selector of the element you want to change
   tagType - the type of tag to change the element to
 ***/
function changeHTMLTag(elemSelector,tagType)
{
    jQuery(elemSelector).replaceWith(
	function()
	{
	    return jQuery("<"+ tagType +">", {class: this.className, html: jQuery(this).html()});
	}
    );
}
// example usage:
changeHTMLTag('#myElement','h2'); // This will change the element into a h2 tag
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript get element position relative to document 
Javascript :: get id by this jquery 
Javascript :: button size react native 
Javascript :: js foreach .childern 
Javascript :: new jsonobject java 
Javascript :: javascript set width percentage update 
Javascript :: javascript json decode 
Javascript :: jquery array 
Javascript :: decompile electron app 
Javascript :: vue shortcut to create component 
Javascript :: react firebase hooks 
Javascript :: new operator in javascript 
Javascript :: settimeout inside loop 
Javascript :: check the string is vowel or not javascript 
Javascript :: get ip address js 
Javascript :: eas build apk 
Javascript :: javascript get ip 
Javascript :: radio button set value in javascript 
Javascript :: get screen resolution jquery 
Javascript :: javascript es6 check if index exists 
Javascript :: jquery version how 
Javascript :: download file javascript 
Javascript :: count duplicate elements in array javascript 
Javascript :: regex for email 
Javascript :: js ajax receive html 
Javascript :: prevent form submission on onsubmit function calls 
Javascript :: how to stop react app in terminal 
Javascript :: jquery await async 
Javascript :: js insert emoji 
Javascript :: discord.js find role by name 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =