最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

.removeClass()

.removeClass( [ className ] ) 返回: jQuery

描述: 移除每個匹配元素的一個,多個或全部樣式。

  • version added: 1.0.removeClass( [ className ] )

    className為每個匹配元素移除的樣式屬性名。

  • version added: 1.4.removeClass( function(index, class) )

    function(index, class)這個函數(shù)返回一個或更多用空格隔開的被移除樣式名。接收元素的索引位置和元素舊的樣式名作為參數(shù)。

如果一個樣式類名作為一個參數(shù),只有這樣式類為匹配的元素集合中被刪除 。 如果沒有樣式名作為參數(shù),那么所有的樣式類將被移除。

從所有匹配的每個元素中同時移除多個用空格隔開的樣式類 ,像這樣:

$('p').removeClass('myClass yourClass')

這個方法通常和 .addClass() 一起使用用來切換元素的樣式, 像這樣:

$('p').removeClass('myClass noClass').addClass('yourClass');

這里從所有段落刪除 myClassnoClass 樣式類, 然后 yourClass 樣式被添加。

用其他樣式類替換現(xiàn)有的樣式類,我們可以使是有 .attr('class', 'newClass') 替換.

在 jQuery 1.4中, .removeClass() 方法允許我們通過函數(shù)來傳遞刪除樣式名。

$('li:last').removeClass(function() {
          return $(this).prev().attr('class');
        });

這個例子從最后一個 <li> 中移除來自倒數(shù)第二的樣式名。

舉例:

例子:從匹配的元素中移除“blue”樣式類。

<!DOCTYPE html>
<html>
<head>
  <style>

  p { margin: 4px; font-size:16px; font-weight:bolder; }
  .blue { color:blue; }
  .under { text-decoration:underline; }
  .highlight { background:yellow; }
  </style>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
	<p class="blue under">Hello</p>
  <p class="blue under highlight">and</p>
  <p class="blue under">then</p>

  <p class="blue under">Goodbye</p>
<script>$("p:even").removeClass("blue");</script>
</body>
</html>

Demo:

例子:從匹配的元素中移除“blue”和“under”樣式類。

<!DOCTYPE html>
<html>
<head>
  <style>
  p { margin: 4px; font-size:16px; font-weight:bolder; }
  .blue { color:blue; }
  .under { text-decoration:underline; }
  .highlight { background:yellow; }
  </style>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
	<p class="blue under">Hello</p>

  <p class="blue under highlight">and</p>
  <p class="blue under">then</p>
  <p class="blue under">Goodbye</p>
<script>$("p:odd").removeClass("blue under");</script>
</body>
</html>

Demo:

例子:從匹配的元素中移除所有樣式類。

<!DOCTYPE html>
<html>
<head>
  <style>

  p { margin: 4px; font-size:16px; font-weight:bolder; }
  .blue { color:blue; }
  .under { text-decoration:underline; }
  .highlight { background:yellow; }
  </style>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
</head>
<body>
	<p class="blue under">Hello</p>
  <p class="blue under highlight">and</p>
  <p class="blue under">then</p>

  <p class="blue under">Goodbye</p>
<script>$("p:eq(1)").removeClass();</script>
</body>
</html>

Demo:

jQuery 1.6 API 中文版腳本之家整理、修訂 (2011年6月)
岢岚县| 芒康县| 九龙坡区| 石嘴山市| 云林县| 临潭县| 信宜市| 安溪县| 丰宁| 平南县| 阿拉善右旗| 博客| 杂多县| 泗洪县| 左权县| 南阳市| 自贡市| 云阳县| 娱乐| 西安市| 大丰市| 观塘区| 泰和县| 天峻县| 松原市| 西乌珠穆沁旗| 广西| 黄浦区| 通州区| 都兰县| 尚义县| 昌邑市| 罗甸县| 徐汇区| 博罗县| 宜良县| 瑞丽市| 永清县| 乌兰察布市| 廊坊市| 秦皇岛市|