html - Show placeholder text as label in Desktop -
this question has answer here:
- hide placeholder css 6 answers
i want show placeholder in mobile view , hide placeholder in desktop view. how this?
end inand mobile view should this:
<label>enter name:</label> <input type="text"/>
and mobile view should this:
<input type="text" placeholder="name">
with jquery :
$(document).ready(function(){ $(window).resize(function(){ var wid = $(this).width(); if((wid > 300) && (wid < 400)) { $('input[type="text"]').attr('placeholder','name'); $('label').hide(); } else { $('input[type="text"]').attr('placeholder',''); $('label').show(); } }) })
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <label>enter name:</label> <input class="int" type="text"/>
Comments
Post a Comment