使用 jQuery 搜索和替换输入占位符文本

Search and replace input placeholder text with jQuery

如何从所有输入框中搜索和替换占位符文本?

示例:我想改变

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

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

通过类似的东西

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

谢谢并致以最诚挚的问候!

根据属性定位元素,然后改变它

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


你可以试试这个:

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