Solved

how can I set all inputs to readonly in jquery?

Posted on 2010-08-25
9
676 Views
Last Modified: 2012-05-10
Hello guys

When I open my page I'd like to set all inputs to readonly, how can I do this?

thanks
0
Comment
Question by:hidrau
9 Comments
 
LVL 3

Expert Comment

by:johnsy32
ID: 33520933
$(":input").attr('readonly','readonly');
0
 
LVL 14

Assisted Solution

by:sam2912
sam2912 earned 100 total points
ID: 33520956
don't need semi-colon
$("input").attr('readonly','readonly');
0
 
LVL 3

Assisted Solution

by:wuff
wuff earned 100 total points
ID: 33520968
use this on all input fields you want to have readonly:

.attr('readonly', true)

Example: $('#inputId').attr('readonly', true);
0
 
LVL 1

Author Comment

by:hidrau
ID: 33521000
can I set them by class?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 1

Author Comment

by:hidrau
ID: 33521011
and to add this attribute how can I add ?

$(). ????
0
 
LVL 1

Author Comment

by:hidrau
ID: 33521021
to remove I do this:

$('#target').removeAttr("disabled");

and to add ?
0
 
LVL 3

Accepted Solution

by:
johnsy32 earned 300 total points
ID: 33521122
By class...

$(".className").attr('readonly','readonly');
0
 
LVL 3

Expert Comment

by:johnsy32
ID: 33521148
to add disabled...

$('#target').attr('disabled','disabled');
0
 
LVL 1

Author Closing Comment

by:hidrau
ID: 33521253
thanks everybody
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show confirmation alert in Jquery 14 43
Css issue on scroll 1 38
What is assert.deepEqual? 4 39
Reference Error with plugin 1 31
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now