jQuery02 使用CSS方式當選擇器實作 元件隱藏+元件選取+事件指定

jQuery02 使用CSS方式當選擇器實作 元件隱藏+元件選取+事件指定

jQuery02 使用CSS方式當選擇器實作 元件隱藏+元件選取+事件指定

 

 

資料來源http://www.w3school.com.cn/jquery/index.asp

code2html:http://tohtml.com/

 

<!DOCTYPE html>
<html>
<head>
<title>jQuery 使用CSS方式當選擇器實作 元件隱藏+元件選取+事件指定</title>
<!--資料來源	http://www.w3school.com.cn/jquery/index.asp-->
<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() 函数,隐藏所有 <p> 元素。
		$(".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>

 

 


發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *