Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8950861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:31:59+00:00 2026-06-15T13:31:59+00:00

I have to disable some elements in my Javas Script code , which one

  • 0

I have to disable some elements in my Javas Script code , which one is better for disabling an element through Java Script :

 1.   document.getElementById("eleId").disabled = true;

 2.   document.getElementById("eleId").disabled = "disabled";

Please anyone describe these functions and what is the difference between these ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:32:00+00:00Added an answer on June 15, 2026 at 1:32 pm

    Both cases are valid.

    In case 1, you are setting the attribute ‘disabled’ to the boolean value ‘true’.
    In case 2, you are setting the attribute ‘disabled’ to the string value ‘disabled’.

    If you were going to set this value via HTML, normally you could get away with just having the bare attribute ‘disabled’ on the tag listed. But for XHTML/XML style compliance, you would use the well formed attribute disabled=”disabled”.

    Basically, if the browser detects that the attribute ‘disabled’ is present, (I think) it will disable the element.

    EDIT
    Another SO user (RobG) pointed out that this sets the ‘DOM property’ of the element in question not the ‘attribute’.

    When dealing with the result from ‘getElementById’, you are dealing with a representation of the structure of the document. When you make modifications you are settings properties on an ‘object model’. Having programmed in Java for so long, I typically interchange the term property & attribute. In the case of saying “it sets the attribute”, I was incorrect. Saying that I were to set the ‘attribute’ would mean that I would have modified the document (HTML) to change the value of “disabled” in the actual source. What this is actually doing is modifying the object tree setting the property of the representative object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file which is transformed with XSL. Some elements have to
I have an empty select element, I want to execute some code when that
I have a form with some select elements. One of them is configured so
On a Jsp page I have some select elements which were disabled after a
I have a checkbox which in some cases may be disabled and checked using
I have to disable and enable three checkboxes. if the user clicks on one
I have one link in a div id where i have to disable the
i have the following code to disable task manager of windows xp but it
I have some JavaScript to toggle a dropdownlists in a ASP.NET page, which gets
Possible Duplicate: What does jQuery.fn mean? I have some script on a page trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.