Reputation: 6707
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
Upvotes: 2
Views: 271
Reputation:
If you want to replace everything:
$('#replace_this').after('#to_this').remove();
Upvotes: 0
Reputation: 9983
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!');
Upvotes: 1
Reputation: 1748
$('div.replaceme1')
.removeClass('replaceme1')
.addClass('Foo')
.html('<p>Some new text</p>')
Have a read of .html(), .removeClass() and .addClass()
Upvotes: 0
Reputation: 14648
$("div.replaceme1")
.html("<p>new text</p>")
.removeClass("replaceme1")
.addClass("SomeNewClassReplacement");
Upvotes: 9