3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
jQuery15 元件選取(html元素+CSS ID)+刪除元素   資料來源:http://www.w3school.com.cn/jquery/index.asp code2html:http://tohtml.com/   <html> <head> <title>jQuery 元件選取(html元素+CSS ID)+刪除元素title> <scriptsrc="http://code.jquery.com/jquery-1.11.3.min.js">script> <scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">script> <script> $(document).ready(function(){ /*HTML+class作為選擇器*/ $("button.empty01").click(function(){ console.log("empty01"); $("#div1").empty(); }); $("button.remove01").click(function(){ console.log("remove01"); $("#div1").remove(); }); }); script> head> <body> <buttontype="button"class="empty01">從被選元素中删除子元素-empty()button> <buttontype="button"class="remove01">删除被選元素(及其子元素)-remove()button> <divid="div1"style="height:100px;width:300px;border:1pxsolidblack;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> body> html>    

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦