我想基于数据属性而不是类名
创建事件<button type="button"
class="btn btn-danger approvalbtn" data-approvestatus="N" data-dismiss="modal">Reject</button>
Now I have added attribute as `$('.approvalbtn').prop("disabled",true);`
我想在jquery
中查看data-approvestatus="N"
答案 0 :(得分:5)
$('button[data-approvestatus=N]').click(function(){
alert("Clicked");
//$(this).prop("disabled",true) you can disable it too
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button"
class="btn btn-danger approvalbtn" data-approvestatus="N" data-dismiss="modal">Reject</button>
&#13;
答案 1 :(得分:1)
您正在寻找属性选择器!这是如何:
$("[data-approvestatus='N']").prop("disabled", true);