我要做的是禁用链接。如果下拉选择值发生变化,如何禁用链接?
如果我选择添加下拉列表,则应禁用编辑和删除链接。帮助
<select id="">
<option value="add" selected="selected">Add</option>
<option value="edit">Edit</option>
<option value="delete">Delete</option>
</select>
<a class="button add" style="cursor:pointer;"><span><b>Add Purchase Request</b></span></a>
<a class="button edit" style="cursor:pointer;"><span><b>Edit Purchase Request</b></span></a>
<a class="button remove" style="cursor:pointer;" name="remove"><span><b>Remove Purchase Request</b></span></a>
答案 0 :(得分:2)
试试这个,
$('select').change(function () {
var va = $(this).val();
if(va=='add'){
$('.remove').attr('disabled', 'disabled');
}
else{
$('.remove').removeAttr('disabled');
}
});
答案 1 :(得分:0)
您可以根据所选选项隐藏锚点:
$('select').change(function () {
var index = $(this).find('option:selected').index();
$('a.button').eq(index).show().siblings('a').hide();
}).change();
<强> Fiddle Demo 强>