I am trying to change type of input, specifically after click into input I need to change type="text"
to type="date"
.
<input type="text" placeholder="DOB" id="dob" name="dob" />
<script>
$("#dob").click(function () {
$(this).attr('type', 'date');
});
</script>
I want to accomplish this for a iphone App. This is not working in iphone 4. How can do this?
Use this code :
<input type="text" placeholder="DOB" id="dob" name="dob" />
<script>
$("#dob").click(function(){
$(this).prop('type', 'date');
});
</script>
Here is the fiddle : http://jsfiddle.net/HNKkW/
It's a property, so prop() will do it :
$("#dob").on('click', function(){
$(this).prop('type', 'date');
});
And remember to wrap that in a document.ready function !
FIDDLE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With