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
simply you can use
$("#yourtextboxid").attr("placeholder", "variable");
where, if variable is string then you can use like above, if it is variable replace it with the name like "variable" with out double quotes.
eg: $("#youtextboxid").attr("placeholder", variable);
it will work.
$(document).ready(function(){
$("input[type=search]").attr("placeholder","this is a test");
});
The plugin doesn't look very robust. If you call .placeholder()
again, it creates a new Placeholder
instance while events are still bound to the old one.
Looking at the code, it looks like you could do:
$("#serMemtb").attr("placeholder", "Type a name (Lastname, Firstname)").blur();
EDIT
placeholder
is an HTML5 attribute, guess who's not supporting it?
Your plugin doesn't really seem to help you overcome the fact that IE doesn't support it, so while my solution works, your plugin doesn't. Why don't you find one that does.
this worked for me:
jQuery('form').attr("placeholder","Wert eingeben");
but now this don't work:
// Prioritize "important" elements on medium.
skel.on('+medium -medium', function() {
jQuery.prioritize(
'.important\\28 medium\\29',
skel.breakpoint('medium').active
);
});
Moving your first line to the bottom does it for me: http://jsfiddle.net/tcloninger/SEmNX/
$(function () {
$('#serMemdd').change(function () {
var k = $(this).val();
if (k == 1) {
$("#serMemtb").attr("placeholder", "Type a name (Lastname, Firstname)").placeholder();
}
else if (k == 2) {
$("#serMemtb").attr("placeholder", "Type an ID").placeholder();
}
else if (k == 3) {
$("#serMemtb").attr("placeholder", "Type a Location").placeholder();
}
});
$('input[placeholder], textarea[placeholder]').placeholder();
});
You can use following code to update a placeholder by id:
$("#serMemtb").attr("placeholder", "Type a Location").val("").focus().blur();