Issue
How can I change the placeholder text of an input element?
For example I have 3 inputs of type text.
<input type="text" name="Email" placeholder="Some Text">
<input type="text" name="First Name" placeholder="Some Text">
<input type="text" name="Last Name"placeholder="Some Text">
How can I change the Some Text text using JavaScript or jQuery?
Solution
If you wanna use Javascript then you can use getElementsByName()
method to select the input
fields and to change the placeholder
for each one... see the below code...
document.getElementsByName('Email')[0].placeholder='new text for email';
document.getElementsByName('First Name')[0].placeholder='new text for fname';
document.getElementsByName('Last Name')[0].placeholder='new text for lname';
Otherwise use jQuery:
$('input:text').attr('placeholder','Some New Text');
Answered By - NazKazi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.