user3532637
user3532637

Reputation: 333

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">

to

<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!

Upvotes: 3

Views: 10257

Answers (2)

user3764415
user3764415

Reputation: 91


You can try this :

    $('input').each(function(index, value) {
     $(this).attr('placeholder','Benutzer');
    });

Upvotes: 0

adeneo
adeneo

Reputation: 318232

Target elements based on the attribute, then change it

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

Upvotes: 10

Related Questions