我正在使用jQuery占位符插件(https://github.com/danielstocks/jQuery-Placeholder)。我需要使用下拉菜单中的更改来更改占位符文本。但这并没有改变。这是代码:
$(function () {
$('input[placeholder], textarea[placeholder]').placeholder();
$('#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();
}
});
});
我的HTML:
<div class="filterbox">
<select name="ddselect" id="serMemdd">
<option value="1" selected="selected">Search by Name</option>
<option value="2">Search by ID</option>
<option value="3">Search by Location</option>
</select>
<input id="serMemtb" type="text" style="width: 490px" placeholder="Type a name (Lastname, Firstname)" />
<input id="seMemBut" type="button" value="Search" />
</div>
谁能解决这个问题?