Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Use JQuery to Find All Readonly Text Boxes on a Web Page

Tags:

jquery

I have been asked to identify all read only text boxes in an Asp.Net page and assign a particular style. I'm pretty sure I could iterate over all of the inputs to see if they were inputs that were text boxes with the readonly attribute but I just KNOW there's a one liner.

Any thoughts?

like image 308
wcm Avatar asked Nov 02 '11 12:11

wcm


People also ask

How check textbox is readonly or not in jQuery?

So use the same attribute "readonly" to find out whether textbox is readonly or not using jQuery. $(document). ready(function(){ $("#txtReadonly"). attr('readonly', true); var isReadonly = $("#txtReadonly").

How can make text field readonly in HTML using jQuery?

How can you make a textbox readonly using JQuery? $('#TextBoxId'). attr('readonly', 'true'); 1.

How can input field readonly in jQuery?

Use jQuery methods to add the readonly attribute to the form input field. jQuery attr() Method: This method set/return attributes and values of the selected elements. If this method is used to return the attribute value, it returns the value of the first selected element.

How do you check if a field is readonly in JavaScript?

Use the readOnly property to check if an element is read-only, e.g. if (element. readOnly) {} . The readOnly property returns true when the element is read-only, otherwise false is returned.


1 Answers

Is this what you're looking for?

$('input[type=text][readonly]')

http://jsfiddle.net/rZvnm/

like image 131
Eliasdx Avatar answered Sep 28 '22 22:09

Eliasdx