search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

jQuery06 元件選取(html元素+CSS ID)+元件隱藏/顯示(具有時間差)+修改元件的CSS的設定值-改變背景顏色 – jashliao部落格

jQuery06 元件選取(html元素+CSS ID)+元件隱藏/顯示(具有時間差)+修改元件的CSS的設定值-改變背景顏色

 

 

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

code2html:http://tohtml.com/

 









<html>
<head>
<title>jQuery 元件選取(html元素+CSS ID)+元件隱藏/顯示(具有時間差)+修改元件的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>
$(document).ready(function(){
/*透過jQuery來修改元件的CSS的設定值-改變背景顏色*/
/*HTML+id作為選擇器*/
$("button#hide").click(function(){
$("p").css("background-color","red");
$("p").hide(1000);
});
/*HTML+class作為選擇器*/
$("button.show").click(function(){
$("p").css("background-color","blue");
$("p").show(1000);
});
});
script>
head>
<body>
<h2>This is a headingh2>
<p>This is a paragraph.p>
<p>This is another paragraph.p>
<buttontype="button"id="hide">hidebutton>
<buttontype="button"class="show">showbutton>
body>
html>

 

 




熱門推薦

本文由 jashliaoeuwordpress 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦