jQuery :password Selector

jQueryWeb DevelopmentFront End Technology

<p>The :password selector in jQuery is used to select input elements with type password.</p><h2>Syntax</h2><p>The syntax is as follows &minus;</p><pre class="result notranslate">$(&quot;:password&quot;)</pre><h2>Example</h2><p>Let us now see an example to implement the jQuery :password selector &minus;</p><pre class="prettyprint notranslate">&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;style&gt; &nbsp; &nbsp;.one { &nbsp; &nbsp; &nbsp; background-color: blue; &nbsp; &nbsp; &nbsp; color: white; &nbsp; &nbsp; &nbsp; font-size: 18px; &nbsp; &nbsp; &nbsp; border: 2px blue dashed; &nbsp; &nbsp;} &lt;/style&gt; &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js&quot;&gt;&lt;/script&gt; &lt;script&gt; &nbsp; &nbsp;$(document).ready(function(){ &nbsp; &nbsp; &nbsp; $(&quot;:password&quot;).addClass(&quot;one&quot;); &nbsp; &nbsp;}); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Login&lt;/h2&gt; &lt;form action=&quot;&quot;&gt; Username: &lt;input type=&quot;text&quot; name=&quot;user&quot;&gt;&lt;br&gt; Password: &lt;input type=&quot;password&quot; name=&quot;password&quot;&gt;&lt;br&gt; &lt;button type=&quot;button&quot;&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre><h2>Output</h2><p>This will produce the following output &minus;</p><p><img src="https://www.tutorialspoint.com/assets/questions/media/30675/password_selector.jpg" class="fr-fic fr-dib" width="600" height="222"></p>
raja
Updated on 05-Nov-2019 12:25:32

Advertisements