Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts

Thursday, December 28, 2023

Readonly checkbox with JQuery using selector.

Readonly checkbox with JQuery using selector.
Add the onclick attribute using the selector with the "return false" value.  
Because the readonly property is not working on the checkbox when clicking on it.

The below code is also not working when the checkbox attribute is readonly.


$('input[name="BeneficiariesList_code"][type="checkbox"][readonly="readonly"]').on("click",function (e) { e.preventDefault(); return false; });

In this line onclick is added by jQuery attr.

$("#BG2").attr("onclick","return false");

<input class="k-checkbox" name="ecode" value="Test" type="checkbox" id="BG2" onclick="return false">