Home > Web Front-end > JS Tutorial > jQuery replace node usage example (using replaceWith method)

jQuery replace node usage example (using replaceWith method)

巴扎黑
Release: 2017-06-24 14:21:48
Original
1279 people have browsed it

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=&#39;苹果&#39;>苹果</li>
<li title=&#39;橘子&#39;>橘子</li>
<li title=&#39;菠萝&#39;>菠萝</li>
</ul>
</body>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template