This article mainly introduces the method of jQuery and combines it with a simple example to analyze the related implementation skills of jQuery using the replaceWith method to replace the P tag display content. Friends in need You can refer to the example below
This article describes how to replace nodes with jQuery. Share it with everyone for your reference, the details are as follows:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="js/jquery-1.10.1.min.js" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ $(function(){ $("p").replaceWith("<strong>你最不喜欢的水果是?</strong>"); // 同样的实现: $("<strong>你最不喜欢的水果是?</strong>").replaceAll("p"); }); //]]> </script> </head> <body> <p title="选择你最喜欢的水果." >你最喜欢的水果是?</p> <ul> <li title='苹果'>苹果</li> <li title='橘子'>橘子</li> <li title='菠萝'>菠萝</li> </ul> </body>
Rendering:
The above is the detailed content of jQuery replace node usage example (using replaceWith method). For more information, please follow other related articles on the PHP Chinese website!