Streamline language to placeholder

Asked

Viewed 55 times

3

I make a request ajax to search in the bank to bring the language configuration, type, EN, PT, and so on...

I want placeholders to be changed according to the chosen language. For example, instead of staying placeholder='Digite seu usuario', I’d like you to stay placeholder='Enter your username' and so it goes...

For block tags (type p, div etc.) I handle so $("#memberArea").html(data.pt.member_area);, and there works perfectly, however, for placeholder I do not know...

Is there any way to manipulate this via jQuery?

1 answer

4


Yes. The placeholder is an element attribute. So you can change it:

function teste() {
	$("#teste").attr("placeholder","Enter your username");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input placeholder="Digite seu usuario" type="text" id="teste" />
<input type="button" value="alterar placeholder p/ inglês" onclick="teste()" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.