背景顯示問題
我加入了邊框? 為何刪除包含3的后顯示會不頂上邊
?.test1 {
? ? ? ? background: #bbffaa;
? ? ? ? width:200px;
? ? ? ? height:100px;
? ? ? ? border:3px solid red;
? ? }
? ??
? ? .test2 {
? ? ? ? background: yellow;
? ? ? ? width:200px;
? ? ? ? height:100px;
? ? ? ? border:3px solid red;
? ? }
? ? </style>
</head>
<body>
? ? <h2>通過jQuery remove方法移除元素</h2>
? ? <div class="test1">
? ? ? ? <p>p元素1</p>
? ? ? ? <p>p元素2</p>
? ? </div>
? ? <div class="test2">
? ? ? ? <p>p元素3</p>
? ? ? ? <p>p元素4</p>
? ? ? ?
? ? </div>
? ? <button>通過點擊jQuery的remove移除元素</button>
? ? <button>通過點擊jQuery的remove移除指定元素</button>
? ? <script type="text/javascript">
? ? $("button:first").on('click', function() {
? ? ? ? //刪除整個 class=test1的div節(jié)點
? ? ? ? $(".test1").remove()
? ? })
? ? $("button:last").on('click', function() {
? ? ? ? //找到所有p元素中,包含了3的元素
? ? ? ? //這個也是一個過濾器的處理
? ? ? ? $("p").remove(":contains('3')")
? ? })
? ? </script>
2018-08-20
p標(biāo)簽有默認(rèn)的margin
2018-05-29