久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      jquery怎么動(dòng)態(tài)增加元素

      方法:1、“元素對(duì)象.append(增加元素)”在內(nèi)部結(jié)尾增加;2、“元素對(duì)象.prepend(增加元素)”在內(nèi)部開(kāi)頭增加;3、“元素對(duì)象.before(增加元素)”在元素的之前增加;4、“元素對(duì)象.after(增加元素)”在元素之后增加。

      jquery怎么動(dòng)態(tài)增加元素

      本教程操作環(huán)境:windows10系統(tǒng)、jquery3.2.1版本、Dell G3電腦。

      jquery怎么動(dòng)態(tài)增加元素

      1、append

      append() 方法在被選元素的結(jié)尾(仍然在內(nèi)部)插入指定內(nèi)容。

      語(yǔ)法為:

      $(selector).append(content)

      示例如下:

      <html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){   $("button").click(function(){     $("p").append(" <b>Hello world!</b>");   }); }); </script> </head> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>在每個(gè) p 元素的結(jié)尾添加內(nèi)容</button> </body> </html>

      輸出結(jié)果:

      jquery怎么動(dòng)態(tài)增加元素

      2、prepend

      prepend() 方法在被選元素的開(kāi)頭(仍位于內(nèi)部)插入指定內(nèi)容。

      語(yǔ)法為:

      $(selector).prepend(content)

      示例如下:

      <html> <head> <script type="text/javascript" src="/jquery/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){   $("button").click(function(){     $("p").prepend("<b>Hello world!</b> ");   }); }); </script> </head> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>在每個(gè) p 元素的開(kāi)頭插入內(nèi)容</button> </body> </html>

      輸出結(jié)果:

      jquery怎么動(dòng)態(tài)增加元素

      3、before

      before() 方法在被選元素之前插入指定的內(nèi)容。

      語(yǔ)法為:

      $(selector).before(content,function(index))

      示例如下:

      </script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").before("<p>Hello world!</p>"); }); }); </script> </head> <body> <button>在P元素之前插入內(nèi)容</button> <p>這是一個(gè)段落。</p> <p>這是另一個(gè)段落。</p> </body>

      輸出結(jié)果:

      jquery怎么動(dòng)態(tài)增加元素

      4、after

      after() 方法在被選元素后插入指定的內(nèi)容。

      語(yǔ)法為:

      $(selector).after(content,function(index))

      示例如下:

      <script> $(document).ready(function(){   $("button").click(function(){     $("p").after("<p>Hello world!</p>");   }); }); </script> </head> <body> <button>在每個(gè)P元素后插入內(nèi)容</button> <p>這是一個(gè)段落。</p> <p>這是另一個(gè)段落。</p> </body>

      輸出結(jié)果:

      jquery怎么動(dòng)態(tài)增加元素

      相關(guān)視頻教程推薦:jQuery視頻教程

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)