Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should try to stick to one way of writing your javascript... plain javascript or jQuery.</p> <p>your code should be the one you can find in <a href="http://jsbin.com/utovaz/2/edit" rel="nofollow">JsBin</a>:</p> <p><strong>HTML</strong></p> <pre><code>&lt;input id="Txt1" runat="server" class="InputField" /&gt; &lt;input id="Txt2" runat="server" class="InputField" /&gt; &lt;input id="Txt3" runat="server" class="InputField" /&gt; </code></pre> <p><strong>Styles</strong></p> <pre><code>.InputField { color: black; font-size: 12px; font-weight: bold; background-color: #7AC5CD; display: block; } .InputFieldSelected { color: white !important; background-color: #90EE90 !important; } </code></pre> <p><strong>Javascript</strong></p> <pre><code>$(function() { $(".InputField") // OnFocus .bind("focus", function() { $(this).toggleClass("InputFieldSelected"); }) // OnBlur .bind("blur", function() { $(this).toggleClass("InputFieldSelected"); }) // Let's focus the first input .filter(":first").focus(); }); </code></pre> <hr> <p>If you want to be simplistic you can <a href="http://jsbin.com/utovaz/2/edit" rel="nofollow">avoid all jQuery binding</a> and use</p> <p><strong>Styles</strong></p> <pre><code> .InputField { color: black; font-size: 12px; font-weight: bold; background-color: #7AC5CD; display: block; } .InputField:focus { color: white !important; background-color: #90EE90 !important; } </code></pre> <p><strong>Javascript</strong></p> <pre><code>$(function() { // Focus on the first input $(".InputField:first").focus(); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload