javascript - How to find a particular button/element using both the data-* and value attribute -
i have 2 dynamically generated buttons:
<button type="button" data-btntyp="btnop" data-usrrole="3" data-reqid="24" class="btn btn-primary btn-xs" style="width: 75px" value="start">start</button> <button type="button" data-btntyp="btnop" data-usrrole="3" data-reqid="24" class="btn btn-primary btn-xs" style="width: 75px" disabled="true" value="complete">complete</button>
the 2 buttons have same data-reqid different values. trying find() button data-reqid="24" , value="complete" , enable button. new jquery , have tried this:
$("button[data-reqid='" + reqid+ "'][value=complete]").attr('disabled', 'false');
but that's syntactically not correct , hence doesn't seem work.
couple of things. if want enable button, need set disabled "false". also, need specify actual boolean value disabled
attribute. don't supply string value of "true"
of "false"
.
in other words, should be"
.attr('disabled', false);
and not:
.attr('disabled', 'false');
full example:
var reqid = 24; $('button[data-reqid="' + reqid+ '"][value="complete"]').attr('disabled', false);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button type="button" data-btntyp="btnop" data-usrrole="3" data-reqid="24" class="btn btn-primary btn-xs" style="width: 75px" value="start">start</button> <button type="button" data-btntyp="btnop" data-usrrole="3" data-reqid="24" class="btn btn-primary btn-xs" style="width: 75px" disabled="true" value="complete">complete</button>
Comments
Post a Comment