I want to locate a div and replace both the content and div class name with another, how to do that
<div class="replaceme1">
replace me 2, too
I want to locate a div and replace both the content and div class name with another, how to do that
<div class="replaceme1">
replace me 2, too
$("div.replaceme1")
.html("<p>new text</p>")
.removeClass("replaceme1")
.addClass("SomeNewClassReplacement");
$('div.replaceme1')
.removeClass('replaceme1')
.addClass('Foo')
.html('<p>Some new text</p>')
Have a read of .html(), .removeClass() and .addClass()
Assuming you use the jQuery library, check out:
to modify it's class. Note that the latter will require you to use quotes.
So, for your example, you would do:
$('div.replaceme1')
.removeClass('BottomSmMargin MiniCheckDiv')
.text('Hello world!');