Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this code and see if it helps. I tried to mimic your example so it makes more sense.</p> <p><strong>HTML</strong></p> <pre><code>&lt;div id="headertxtPassWord-Container" class="header-login-input-Container"&gt; &lt;input id="headertxtPassWord" value="password" class="header-login-input" /&gt; &lt;/div&gt; </code></pre> <p><strong>JQuery</strong></p> <pre><code>$('.header-login-input').bind('click', function() { if ($(this).val() === "password") { this.type = "password"; $(this).val(''); } }); $('.header-login-input').bind('blur', function() { if ($(this).val() === "") { this.type = "text"; $(this).val('password'); } }); </code></pre> <p>Also a js fiddler to see a working example <a href="http://jsfiddle.net/V2Dh5/3/" rel="nofollow">http://jsfiddle.net/V2Dh5/3/</a></p> <p><strong>Edited</strong></p> <p>This is the fix for IE 8</p> <pre><code>$('.header-login-input').live('click', PopulateElement); $('.header-login-input').live('blur', function() { if ($(this).val() === "") { $(".header-login-input-Container").html(''); $(".header-login-input-Container").html("&lt;input id=\"headertxtPassWord\" name=\"headertxtPassWord\" class=\"header-login-input\" value=\"password\" type=\"text\"/&gt;"); } }); function PopulateElement () { if ($(this).val() === "password") { $(".header-login-input-Container").html(''); $(".header-login-input-Container").html("&lt;input id=\"headertxtPassWord\" name=\"headertxtPassWord\" class=\"header-login-input\" type=\"password\"/&gt;"); setTimeout(function() { $("#headertxtPassWord").focus()}, 10); } } </code></pre> <p>Look at the js fiddler at <a href="http://jsfiddle.net/V2Dh5/17/" rel="nofollow">http://jsfiddle.net/V2Dh5/17/</a></p>
 

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