I can put a placeholder through jQuery if there is a single <input> on the page:
<input type="text"/>
$(document).ready(function() {
placeholders();
function placeholders() {
$('input[type=text]').each(function() {
$(this).attr('placeholder', 'hello' );
});
}
});
However, I have multiple <input> fields in a single page as below:
<input type="text" class="first">
<input type="text" class="second">
I wish to add a placeholder only on the first <input type="text"> that has class="first".
How can I add a placeholder to the first matching text input only?