jquery-mobile/experiments/api-viewer/docs/class-selector/index.html
2010-11-01 21:46:29 -04:00

90 lines
No EOL
3.1 KiB
HTML

<!DOCTYPE html>
<html lang='en'><head>
<meta charset="utf-8" /><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
<div data-role="page">
<div data-role="header">
<h1>Class Selector (“.class”)</h1>
<div class="entry-meta">Categories:
<span class="category"><a href="http://api.jquery.com/category/selectors/" title="View all posts in Selectors">Selectors</a> &gt; <a href="http://api.jquery.com/category/selectors/basic-css-selectors/" title="View all posts in Basic">Basic</a></span>
</div>
</div>
<div data-role="content" data-theme="c" id="class1">
<h2 class="jq-clearfix roundTop section-title">
<span class="name">class</span> selector</h2>
<div class=" entry-details">
<h4 class="name">
<span class="versionAdded">version added: <a href="/version/1.0/">1.0</a></span>jQuery('.class')</h4>
<ul class="signatures"><li><dl class="arguments">
<dt>class</dt>
<dd>A class to search for. An element can have multiple classes; only one of them must match.</dd>
</dl></li></ul>
<p class="desc"><strong>Description: </strong>Selects all elements with the given class. </p>
<div class="longdesc"><p>For class selectors, jQuery uses JavaScript's native <code>getElementsByClassName()</code> function if the browser supports it.</p></div>
<h3>Examples:</h3>
<div id="entry-examples" class="entry-examples">
<div id="example-0">
<h4>Example: <span class="desc">Finds the element with the class "myClass".</span>
</h4>
<pre><code class="example demo-code">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
div,span {
width: 100px;
height: 40px;
float:left;
padding: 10px;
margin: 10px;
background-color: #EEEEEE;
}
&lt;/style&gt;
&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="notMe"&gt;div class="notMe"&lt;/div&gt;
&lt;div class="myClass"&gt;div class="myClass"&lt;/div&gt;
&lt;span class="myClass"&gt;span class="myClass"&lt;/span&gt;
&lt;script&gt;$(".myClass").css("border","3px solid red");&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h4>Demo:</h4>
<div class="demo code-demo"></div>
</div>
<div id="example-1">
<h4>Example: <span class="desc">Finds the element with both "myclass" and "otherclass" classes.</span>
</h4>
<pre><code class="example demo-code">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
div,span {
width: 100px;
height: 40px;
float:left;
padding: 10px;
margin: 10px;
background-color: #EEEEEE;
}
&lt;/style&gt;
&lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=".myclass"&gt;div class="notMe"&lt;/div&gt;
&lt;div class="myclass otherclass"&gt;div class="myClass"&lt;/div&gt;
&lt;span class="myclass otherclass"&gt;span class="myClass"&lt;/span&gt;
&lt;script&gt;$(".myclass.otherclass").css("border","13px solid red");&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<h4>Demo:</h4>
<div class="demo code-demo"></div>
</div>
</div>
</div>
</div>
</div>
</body></html>