[Селектор] class
Раздел "Selectors"
Выбор всех элементов по определенному классу.
Параметры
Пример
class
Примеры
Пример:
Найти элементы с классом "myClass".
"HTML"
<div class="notMe">div class="notMe"</div> <div class="myClass">div class="myClass"</div> <span class="myClass">span class="myClass"</span>
"CSS"
div,span { width: 150px; height: 60px; float:left; padding: 10px; margin: 10px; background-color: #EEEEEE; }
"Живой пример jQuery"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link href="http://test-drupal.ru/themes/slyweb/css/jqueryiframe.css" rel="stylesheet" type="text/css"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script> $(document).ready(function(){ $(".myClass").css("border","3px solid red"); }); </script> </head> <body class="iframe"> <div class="notMe">div class="notMe"</div> <div class="myClass">div class="myClass"</div> <span class="myClass">span class="myClass"</span> </body> </html> <style> div,span { width: 150px; height: 60px; float:left; padding: 10px; margin: 10px; background-color: #EEEEEE; } </style>
Пример:
Найти элементы с классами "myClass", "myClass1".
"HTML"
<div class="notMe">div class="notMe"</div> <div class="myClass">div class="myClass"</div> <span class="myClass1">span class="myClass1"</span>
"CSS"
div,span { width: 150px; height: 60px; float:left; padding: 10px; margin: 10px; background-color: #EEEEEE; }
"Живой пример jQuery"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link href="http://test-drupal.ru/themes/slyweb/css/jqueryiframe.css" rel="stylesheet" type="text/css"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script> $(document).ready(function(){ $(".myClass, .myClass1").css("border","3px solid red"); }); </script> </head> <body class="iframe"> <div class="notMe">div class="notMe"</div> <div class="myClass">div class="myClass"</div> <span class="myClass1">span class="myClass1"</span> </body> </html> <style> div,span { width: 150px; height: 60px; float:left; padding: 10px; margin: 10px; background-color: #EEEEEE; } </style>
Версия jQuery 1.4.2
Документ создан 2010-08-21