Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how can I set all inputs to readonly in jquery?

Posted on 2010-08-25
9
Medium Priority
?
700 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 3

Expert Comment

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

Assisted Solution

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

Assisted Solution

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

.attr('readonly', true)

Example: $('#inputId').attr('readonly', true);
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 1

Author Comment

by:hidrau
ID: 33521000
can I set them by class?
0
 
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 1200 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

730 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