I am using a jQuery placeholder plugin(https://github.com/danielstocks/jQuery-Placeholder). I need to change the placeholder text with the change in dropdown menu. But it is
If the input is inside the div than you can try this:
$('#div_id input').attr("placeholder", "placeholder text");
change placeholder text using jquery
try this
$('#selector').attr("placeholder", "Type placeholder");
$(document).ready(function(){
$('form').find("input[type=search]").each(function(ev)
{
$(this).attr("placeholder", "Search Whatever you want");
});
});
working example of dynamic placeholder using Javascript and Jquery http://jsfiddle.net/ogk2L14n/1/
<input type="text" id="textbox">
<select id="selection" onchange="changeplh()">
<option>one</option>
<option>two</option>
<option>three</option>
</select>
function changeplh(){
debugger;
var sel = document.getElementById("selection");
var textbx = document.getElementById("textbox");
var indexe = sel.selectedIndex;
if(indexe == 0) {
$("#textbox").attr("placeholder", "age");
}
if(indexe == 1) {
$("#textbox").attr("placeholder", "name");
}
}
$(document).ready(function(){
$('form').find("input[type=textarea], input[type=password], textarea").each(function(ev)
{
if(!$(this).val()) {
$(this).attr("placeholder", "Type your answer here");
}
});
});
Copy and paste this code in your js file, this will change all placeholder text from whole site.
try this
$('#Selector_ID').attr("placeholder", "your Placeholder");