How to Enable or Disable HTML Form Elements Using jQuery

Disable HTML Inputs

From jQuery 1.7, you could use the prop() method. Before 1.7, you have the option of using the attr() method. Both of these methods can be used in the same way for this purpose.

jQuery 1.7+

Prior to jQuery 1.7

You may also use $(“:text”) or $(‘input[type=”text”]’) to select all elements of type text. You can also use $(“#inputid”) to select a particular element by id.

Because :text is a jQuery extension and not part of the CSS specification, queries using :text cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use [type=”text”] instead.

Read Also  Here's How to Add Scrollbars to an iframe in HTML