jQuery 中的 Insertafter方法函数

首页 / jQuery入门教程 / jQuery 中的 Insertafter方法函数

insert After(selector)方法将所有匹配的元素插入到另一个指定的元素集之后。

Insertafter - 语法

selector.insertAfter( selector )

下面是此方法-使用的所有参数的说明

Insertafter - 示例

<html>
   <head>
      <title>The jQuery Example</title>
      <script type="text/javascript" 
         src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
      </script>
		
      <script type="text/javascript" language="javascript">
         $(document).ready(function() {
            $("div").click(function () {
               $("#source").insertAfter(this);
            });
         });
      </script>
		
      <style>
         .div{ margin:10px;padding:12px; border:2px solid #666; width:60px;}
      </style>
   </head>
	
   <body>
      <p>Click on any square below to see the result:</p>
		
      <div class="div" id="source"></div>
      <div class="div" style="background-color:blue;"></div>
      <div class="div" style="background-color:green;"></div>
      <div class="div" style="background-color:red;"></div>
   </body>
</html>

这将产生以下输出-

无涯教程网

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

左耳听风 -〔陈皓〕

持续交付36讲 -〔王潇俊〕

跟月影学可视化 -〔月影〕

技术管理案例课 -〔许健〕

说透芯片 -〔邵巍〕

JavaScript进阶实战课 -〔石川〕

云计算的必修小课 -〔吕蕴偲〕

B端体验设计入门课 -〔林远宏(汤圆)〕

云时代的JVM原理与实战 -〔康杨〕

好记忆不如烂笔头。留下您的足迹吧 :)