jQuery Selector :disabled

Introduction

The :disabled selector selects all disabled form elements.

$(":disabled")

Select all the disabled form elements:

View in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
  $(":disabled").css("background-color", "red");
});//from ww  w . ja  va  2  s. c  o  m
</script>
</head>
<body>

<form action="">
name: <input type="text" name="user"><br>
id:<input type="text" name="id" disabled="disabled">

age:
<select disabled="disabled">
  <option>2</option>
  <option>3</option>
  <option>5+</option>
</select>
<input type="submit">
</form>

</body>
</html>



PreviousNext

Related