<!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>
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $('#btn1').click(function(){ $('#myspan').html('This is a <i>italic text</i>.This is another <i>italic text</i>.'); }); }); </script> </head> <body> <button id="btn1">Exampleof html(Content)</button> <span id="myspan">This is a <b>bold text</b>.This is another <b>bold text</b>.</span> </body> </html>
<span id="myspan">This is a <i>italic text</i>.This is another <i>italic text</i>.</span>
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script> $(document).ready(function(){ $('#btn1').click(function(){ $('#myspan').replaceWith('This is a <i>italic text</i>.This is another <i>italic text</i>.'); }); }); </script> </head> <body> <button id="btn1">Exampleof replaceWith(Content)</button> <span id="myspan">This is a <b>bold text</b>.This is another <b>bold text</b>.</span> </body> </html>
This is a <i>italic text</i>.This is another <i>italic text</i>.