Reputation: 716
I try to delete or replace this HTML tag from my code.
<li class="li-sortable-background">
I have try with replace, but i replace only text and can't replace code characters like <=""> and stuff. I need help please!
Upvotes: 0
Views: 269
Reputation: 69
$( ".li-sortable-background" ).replaceWith("<h2>your vale</h2>");
Upvotes: 0
Reputation: 4309
You can use following code
Using JQuery :
$("#div1").remove();
Removing elements by class name:
$('.className').remove();
Using javascript :
var child = document.getElementById("divId");
child.parentNode.removeChild(child);
Upvotes: 0
Reputation: 716
Sorry, its a string like this and i give it out in a textarea value. I just want to remove LI with class etc.
<form name="asd" id="freeld_form" class="sortable ui-sortable" action="" method="get">
<li class="li-sortable-background">
<label for="asd" id="aha"></label>
<input name="asd" id="asd" class="" placeholder="" type="">
<button class="deleteButton"><img src="images/delete-button.svg" title="Load File"></button>
</li>
</form>
Upvotes: 0
Reputation: 14604
Try this. Supposing that you have only one element with this class.
document.getElementsByClassName('li-sortable-background')[0].remove()
Upvotes: 0
Reputation: 141
Use .remove() method when you want to remove the element itself, as well as everything inside it.
Upvotes: 2