萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> 數據庫綜合 >> jQuery 入門教程

jQuery 入門教程

這篇文章主要介紹了jQuery 入門教程的相關內容,下面我們就與大家一起分享。

jQuery 入門教程

刪除HTML元素

jQuery使用下面兩個方法來刪除或是清空某個HTML元素。

remove() – 刪除指定的元素(包括其子元素)

empty() – 清空指定元素的子元素

例如:

[html]

This is some text in the div.

This is a paragraph in the div.

This is another paragraph in the div

Remove div element

This is some text in the div.

This is a paragraph in the div.

This is another paragraph in the div.

Remove div element

jQuery 入門

empty() 示例:

[html]

This is some text in the div.

This is a paragraph in the div.

This is another paragraph in the div.

Empty the div element

This is some text in the div.

This is a paragraph in the div.

This is another paragraph in the div.

Remove div element

jQuery 入門

empty() 示例:

[html]

This is some text in the div.

This is a paragraph in the div.

This is another paragraph in the div.

Empty the div element

This is some text in the div.

This is a paragraph in the div.

This is another paragraph in the div.

Empty the div element

jQuery 入門

jQuery的remove()方法也支持一個參數,可以用於過濾一些需要刪除的HTML元素。這參數可以為任何有效的ry selector.比如下面代碼只刪除class=”italic”的jQue元素:

 

[javascript]

$("p").remove(".italic");

$("p").remove(".italic");

以上就是我們為大家准備的jQuery 入門的相關內容,希望對大家可以有所幫助。

copyright © 萬盛學電腦網 all rights reserved