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

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
jQuery02 使用CSS方式當選擇器實作 元件隱藏+元件選取+事件指定     資料來源:http://www.w3school.com.cn/jquery/index.asp code2html:http://tohtml.com/   <html> <head> <title>jQuery 使用CSS方式當選擇器實作 元件隱藏+元件選取+事件指定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> /* $(this).hide() 演示 jQuery hide() 函数,隐藏当前的 HTML 元素。 $("#test").hide() 演示 jQuery hide() 函数,隐藏 id="test" 的元素。 $("p").hide() 演示 jQuery hide() 函数,隐藏所有 元素。 $(".test").hide() 演示 jQuery hide() 函数,隐藏所有 class="test" 的元素。 */ $(document).ready(function(){ /* //所有p都指定事件 $("p").click(function(){ $(this).hide();//指定目前元件執行隱藏動作 }); */ //單純使用ICSS ID當選擇器 $("#test").click(function(){ $(this).hide();//指定目前元件執行隱藏動作 }); //單純使用ICSS ID當選擇器 $(".test").click(function(){ $(this).hide();//指定目前元件執行隱藏動作 }); }); script> head> <body> <pid="test">如果您点击我,我会消失。p> <pclass="test">点击我,我会消失。p> <p>也要点击我哦。p> body> html>    

本文由jashliaoeuwordpress提供 原文連結

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