Answer: replaceAll() method replaces all the selected elements with new HTML elements
e.g. te below code replace all the bold (b) elements with i(italic) elements with the text inside the b tag
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("<i>italic text</i>").replaceAll("b");
});
});
</script>
</head>
<body>
<button>Replace all b(bold) elements with i(italic) elements</button><br>
<p>This is a <b>bold text</b>.This is another <b>bold text</b>.</p>
</body>
</html>
Asked In: Many Interviews |
Alert Moderator