user3532637 user3532637 - 4 months ago 10
jQuery Question

Search and replace input placeholder text with jQuery

How can I search and replace placeholder text from all input boxes?

Example: I wanna change

<input type="text" name="user" id="user" placeholder="User">


<input type="text" name="user" id="user" placeholder="Benutzer">

By something like that

$('input').each(function() {
$(this).attr("placeholder").replace('User', 'Benutzer');

Thanks and best regards!


Target elements based on the attribute, then change it

$('input[placeholder="User"]').attr('placeholder', 'Benutzer')