在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ HTML/ 刪除HTML元素
jQuery UI Tab 示例(一)
jQuery UI Datepicker 示例(四)
jQuery UI 示例
jQuery UI Slider 示例(二)
jQuery UI Dialog 示例(一)
HTML Get
動(dòng)畫效果
終止動(dòng)畫
回調(diào)函數(shù)
方法鏈
jQuery UI Button 示例(一)
jQuery UI Autocomplete 示例(三)
jQuery UI Autocomplete 示例(二)
設(shè)置或取得元素的 CSS class
jQuery UI 概述
基本語法
jQuery UI Datepicker 示例(一)
jQuery UI Autocomplete 示例(一)
jQuery UI Spiner 示例
jQuery UI Tab 示例(二)
淡入淡出效果
顯示/隱藏內(nèi)容
HTML Set
jQuery UI Tooltip 示例
jQuery UI Slider 示例(一)
讀寫 HTML 元素的 css 屬性
jQuery UI Datepicker 示例(二)
添加HTML元素
操作 HTML 元素的大小
jQuery UI Datepicker 示例(五)
滑動(dòng)效果
jQuery UI Dialog 示例(二)
jQuery UI Menu 示例
jQuery UI 基本工作過程
jQuery UI Button 示例(二)
jQuery UI Dialog 示例(三)
jQuery UI Datepicker 示例(三)
Selectors
jQuery UI Progressbar 示例
Events
jQuery UI Accordion 示例
刪除HTML元素

刪除HTML元素

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

  • remove() – 刪除指定的元素(包括其子元素)
  • empty() – 清空指定元素的子元素

例如:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>JQuery Demo</title>
    <script src="scripts/jquery-1.9.1.js"></script>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $("#div1").remove();
            });
        });
    </script>
</head>
<body>

    <div id="div1" style="height: 100px; width: 300px;
        border: 1px solid black; background-color: yellow;">
        This is some text in the div.
        <p>This is a paragraph in the div.</p>
        <p>This is another paragraph in the div.</p>

    </div>
    <br>
    <button>Remove div element</button>

</body>
</html>

http://wiki.jikexueyuan.com/project/jquery-tutorial/images/9.png" alt="" />

empty()示例:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>JQuery Demo</title>
    <script src="scripts/jquery-1.9.1.js"></script>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $("#div1").empty();
            });
        });
    </script>
</head>
<body>

    <div id="div1" style="height: 100px; width: 300px;
        border: 1px solid black; background-color: yellow;">
        This is some text in the div.
        <p>This is a paragraph in the div.</p>
        <p>This is another paragraph in the div.</p>

    </div>
    <br>
    <button>Empty the div element</button>

</body>
</html>

http://wiki.jikexueyuan.com/project/jquery-tutorial/images/10.png" alt="" />

jQuery 的 remove()方法也支持一個(gè)參數(shù),可以用于過濾一些需要?jiǎng)h除的 HTML 元素。這個(gè)參數(shù)可以為任何有效的 jQuery selector. 比如下面代碼只刪除 class=”italic”的

元素:

$("p").remove(".italic");
上一篇:滑動(dòng)效果下一篇:HTML Get