Disable all any elements who has class name [Resolved]

Posted by Vishalneeraj-24503 under jQuery on 3/13/2018 | Points: 10 | Views : 395 | Status : [Member] [MVP] | Replies : 1
Hi All,

I want to disable all elements who contains class name pqr.
<input class = "abc pqr" id = "txt" type="text">
<input class = "abc pqr" id = "chk" type="checkbox">
<input class = "xyz pqr" id = "file" type="file">
<input class = "abc pqr" id = "date" type="date">
<select class = "abc pqr">
<input class = "pqr" id = "date" type="radio">


How to achieve above things.




Responses

Posted by: Rajnilari2015 on: 3/14/2018 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
You can achieve as
$(".pqr").attr("disabled", true);


e.g.


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$(".pqr").attr("disabled", true);
});
});
</script>
</head>
<body>

<input class = "abc pqr" id = "txt" type="text">
<input class = "abc pqr" id = "chk" type="checkbox">
<input class = "xyz pqr" id = "file" type="file">
<input class = "abc pqr" id = "date" type="date">
<select class = "abc pqr">
<input class = "pqr" id = "date" type="radio">
<input class = "someelseclass" id = "date" type="text">
<p></p>

<button>Click me</button>

</body>
</html>


Upon clicking on "Click Me" button except element with class = "someelseclass", all are disabled.



--
Thanks & Regards,
RNA Team

Vishalneeraj-24503, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response