title: I want to set placeholder to textbox using data-* attribute in html using jQuery?
body: <p>I want to set placeholder using data-* attribute. I tried with jQuery. but not working. if i use id instead of all input type. its working.</p>
  
  <p>but i want common code to set placeholder for any input text fields in a page.</p>
  
  <h2>html:</h2>
  
  <pre><code>&lt;p&gt;Login&lt;/p&gt;
  &lt;input type="text" data-placeholder="Email" id="txtemail" /&gt;
  &lt;input type="password" data-placeholder="Password" id="txtpass" /&gt;
  </code></pre>
  
  <h2>jQuery:</h2>
  
  <pre><code>foctext = $('input:text').attr("data-placeholder");
  $(this).val(foctext);
  $(this).focus(function () {
      if ($(this).val() == foctext) {
          $(this).val("");
      }
  });
  $(this).blur(function () {
      if ($(this).val() == "") {
          $(this).val(foctext);
      }
  });
  </code></pre>
  
  <p>please write correct solution for this. thank you</p>