我正在使用一个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>
有人能算出来吗?