国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

jQuery常用樣式操作實例分析(獲取、設置、追加、刪除、判斷等)

2019-11-20 09:02:51
字體:
來源:轉載
供稿:網友

本文實例分析了jQuery常用樣式操作。分享給大家供大家參考,具體如下:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title><style type="text/css">.high {  font-weight: bold; /* 粗體字 */  color : red; /* 字體顏色設置紅色*/}.another {  font-style: italic;  color: blue;}</style><script src="js/jquery-1.10.1.min.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[$(function(){  //獲取樣式  $("input:eq(0)").click(function(){    alert( $("p").attr("class") );  });  //設置樣式  $("input:eq(1)").click(function(){    $("p").attr("class","high");  });  //追加樣式  $("input:eq(2)").click(function(){    $("p").addClass("another");  });  //刪除全部樣式  $("input:eq(3)").click(function(){    $("p").removeClass();  });  //刪除指定樣式  $("input:eq(4)").click(function(){    $("p").removeClass("high");  });  //重復切換樣式  $("input:eq(5)").click(function(){    $("p").toggleClass("another");  });  //判斷元素是否含有某樣式  $("input:eq(6)").click(function(){    alert( $("p").hasClass("another") )    alert( $("p").is(".another") )  });});//]]></script></head><body><input type="button" value="輸出class類"/><input type="button" value="設置class類"/><input type="button" value="追加class類"/><input type="button" value="刪除全部class類"/><input type="button" value="刪除指定class類"/><input type="button" value="重復切換class類"/><input type="button" value="判斷元素是否含有某個class類"/><p class="myClass" title="選擇你最喜歡的水果." >你最喜歡的水果是?</p><ul>  <li title='蘋果'>蘋果</li>  <li title='橘子'>橘子</li>  <li title='菠蘿'>菠蘿</li></ul></body></html>

效果圖:

更多關于jQuery相關內容感興趣的讀者可查看本站專題:《jQuery擴展技巧總結》、《jQuery常用插件及用法總結》、《jQuery拖拽特效與技巧總結》、《jQuery表格(table)操作技巧匯總》、《jquery中Ajax用法總結》、《jQuery常見經典特效匯總》、《jQuery動畫與特效用法總結》及《jquery選擇器用法總結

希望本文所述對大家jQuery程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大安市| 天柱县| 团风县| 讷河市| 宁波市| 齐齐哈尔市| 惠来县| 焉耆| 顺义区| 红桥区| 忻州市| 阜康市| 犍为县| 磐安县| 清丰县| 城市| 调兵山市| 天峻县| 蕲春县| 伊金霍洛旗| 双江| 加查县| 蒙山县| 城步| 望谟县| 泸定县| 阳新县| 石柱| 蕉岭县| 织金县| 玉树县| 分宜县| 磴口县| 平罗县| 梁平县| 怀来县| 都昌县| 包头市| 合阳县| 镇原县| 丁青县|