Why do we use replaceAll() method in jQuery?

 Posted by Rajnilari2015 on 12/19/2015 | Category: jQuery Interview questions | Views: 1981 | Points: 40

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>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
$("<i>italic text</i>").replaceAll("b");

<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>

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response