欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

基于jQuery選擇器之表單對象屬性篩選選擇器的實(shí)例

 更新時間:2017年09月19日 08:18:53   作者:喵嘻嘻  
下面小編就為大家?guī)硪黄猨Query選擇器之表單對象屬性篩選選擇器實(shí)例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <title></title>
  <link rel="stylesheet" href="imooc.css" rel="external nofollow" type="text/css">
  <style>
  input {
    display: block;
    margin: 10px;
    padding: 10px;
  }
  </style>
  <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
</head>

<body>
  <h2>子元素篩選選擇器</h2>
  <h3>enabled、disabled</h3>
  <form>
    <input type="text" value="未設(shè)置disabled" />
    <input type="text" value="設(shè)置disabled" disabled />
    <input type="text" value="未設(shè)置disabled" />
  </form>

  <script type="text/javascript">
    //查找所有input所有可用的(未被禁用的元素)input元素。
    $("input:enabled").css("border", "2px groove red");
  </script>

  <script type="text/javascript">
    //查找所有input所有不可用的(被禁用的元素)input元素。
    $("input:disabled").css("border", "2px groove blue");
  </script>

  <h3>checked、selected</h3>
  <form>
    <input type="checkbox" checked="checked">
    <input type="checkbox">
    <input type="radio" checked>    
    <input type="radio">
    
    <select name="garden" multiple="multiple">
      <option>imooc</option>
      <option selected="selected">慕課網(wǎng)</option>
      <option>aaron</option>
      <option selected="selected">博客園</option>
     </select>

  </form>

  <script type="text/javascript">
     //查找所有input所有勾選的元素(單選框,復(fù)選框)
     //移除input的checked屬性
    $("input:checked").removeAttr('checked')
  </script>

  <script type="text/javascript">
     //查找所有option元素中,有selected屬性被選中的選項
     //移除option的selected屬性
    $("option:selected").removeAttr('selected')
  </script>

</body>

</html>

注意:

在某些瀏覽器中,選擇器:checked可能會錯誤選取到<option>元素,所以保險起見換用選擇器input:checked,確保只會選取<input>元素

以上這篇jQuery選擇器之表單對象屬性篩選選擇器實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論