{"id":18295,"date":"2017-08-18T12:15:21","date_gmt":"2017-08-18T09:15:21","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=18295"},"modified":"2017-08-18T16:52:15","modified_gmt":"2017-08-18T13:52:15","slug":"enabledisable-element-using-jquery-javascript-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/","title":{"rendered":"How to enable\/disable an element using jQuery and JavaScript? Example"},"content":{"rendered":"<p>Sometimes we need to enable and disable input elements e.g. text box, radio buttons or checkbox, how can we do it dynamically without loading the page? Well, we can use JavaScript, particularly jQuery to do this. An element can be disabled in HTML by setting disable property to true and enabled again by setting disabled=false. By using jQuery, we can grab the element we want to enable or disable and change this property by using prop() or attr() function, depending upon which version of jQuery you are using. prop() function was added in jQuery 1.6 and its the standard way to deal with properties but attr() function does the same job for jQuery 1.5 and lower version so you can use attr() for the same purpose in jQuery version lower than 1.6.<\/p>\n<p>Btw, you can also enable or disable any HTML element e.g. input text field using plain old JavaScript. All you need to do is get the element by id and set its disabled property to true or false. You can do that when a user clicks on some button by calling a JavaScript function by using the<br \/>\nonclick attribute as shown in our first example.<\/p>\n<h2>How to enable\/disable text field using JavaScript<\/h2>\n<p>In this example, we have an HTML form, text boxes, and a couple buttons to enable and disable that text field. I am using plain JavaScript, no jQuery yet to accomplish the task. The steps are as follows:<\/p>\n<p>1) Register enable() and disable() function with buttons to enable and disable text field<\/p>\n<p>2) Use getElementById() to grab the text field<\/p>\n<p>3) Set the disabled field to true or false<\/p>\n<p>Here is the sample HTML file with JavaScript solution:<\/p>\n<pre class=\"brush:xml\">&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;How to enable or disable input using JavaScript&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;h2&gt;Enabling and Disabling text field using JavaScript&lt;\/h2&gt;\r\n\r\n&lt;form id=\"registration-form\"&gt;\r\nEnter your name: &lt;input type=\"text\" id=\"name\"&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;button onclick=\"disable()\"&gt;Disable the text field&lt;\/button&gt;\r\n&lt;button onclick=\"enable()\"&gt;Enable the text field&lt;\/button&gt;\r\n\r\n&lt;script&gt;\r\nfunction disable() {\r\ndocument.getElementById(\"name\").disabled = true;\r\n}\r\nfunction enable() {\r\ndocument.getElementById(\"name\").disabled = false;\r\n}\r\n&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>When you click the button &#8220;Disable the text field&#8221;, the disable() function will be called and disabled property of text field will be set to true, which means you cannot enter text on this text field anymore, it&#8217;s disabled. You can re-enable the text field by clicking on &#8220;Enable the text field&#8221; button, it will call the enable() function which will reset the disabled property to false.<\/p>\n<h2>How to enable\/disable text field using jQuery?<\/h2>\n<p>Here is the jQuery code to do the same thing. In this example, we have used prop() function, if you are running on jQuery 1.5 or lower version, just replace the prop() with attr() and it should work fine. Similar to the previous example, we have two buttons btn_enable and btn_disable to enable and disable the text field.<\/p>\n<p>We attach the event handler using click() function at\u00a0<a href=\"http:\/\/javarevisited.blogspot.sg\/2014\/11\/difference-between-jquery-document-ready-vs-Javascript-window-onload-event.html\" target=\"_blank\" rel=\"noopener\">$(document).ready()<\/a> which called after page is loaded. On event handler we grab the text field by using jQuery ID selector e.g. $(&#8220;#name&#8221;) and then called prop(&#8220;disabled&#8221;, false&#8221;) to disable this text field.<\/p>\n<p>When a user calls the enable button we just set the disabled property to true by calling prop(&#8220;disabled&#8221;, true). This enabled the text field again. Remember, you cannot enter text into a disabled text field.<\/p>\n<pre class=\"brush:xml\">&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;How to enable or disable textfield using jQuery&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n\r\n&lt;body&gt;\r\n\r\n&lt;h2&gt;Enabling and Disabling text field using jQuery&lt;\/h2&gt;\r\n\r\n&lt;form id=\"registration-form\"&gt;\r\nEnter your name: &lt;input type=\"text\" id=\"name\"&gt;\r\n&lt;\/form&gt;\r\n\r\n&lt;button id=\"btn_disable\" &gt;Disable the input&lt;\/button&gt;\r\n&lt;button id=\"btn_enable\" &gt;Enable the input&lt;\/button&gt;\r\n\r\n\r\n&lt;script src=\"http:\/\/code.jquery.com\/jquery-1.6.2.min.js\"&gt;&lt;\/script&gt;\r\n&lt;script&gt;\r\n$(document).ready(function() {\r\n\r\n$(\"#btn_enable\").click(function(){\r\n$(\"#name\").prop(\"disabled\", false);\r\n});\r\n\r\n$(\"#btn_disable\").click(function(){\r\n$(\"#name\").prop(\"disabled\", true);\r\n});\r\n\r\n});\r\n&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>You can test this by running in your browser. Just remember, not to call removeProp() function to enable the button again e.g.\u00a0<b>removeProp(&#8220;disabled&#8221;)<\/b> because it will remove the &#8220;disabled&#8221; attribute from the text field and it won&#8217;t be possible to disable it again in future, instead just use prop(&#8220;disabled&#8221;, false) method. Btw, if you are new to jQuery I suggest you to first go through<br \/>\n<a href=\"http:\/\/www.shareasale.com\/m-pr.cfm?merchantID=53701&amp;userID=880419&amp;productID=687367587\" target=\"_blank\" rel=\"nofollow noopener\">jQuery: Getting Started By Craig Shoemaker<\/a> to learn basic stuff.<\/p>\n<p>Here is the screenshot of how it will look like when you open the page in a browser like Edge or Chrome.<\/p>\n<p><a href=\"http:\/\/javarevisited.blogspot.gr\/2013\/07\/jquery-selectors-examples-ID-Class-Descendent-Child-Multiple-Pseudo-Selector-find-element-DOM.html\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-18298\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/08\/How-to-enable-disable-text-fields-using-jQUery.png\" alt=\"\" width=\"640\" height=\"336\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/08\/How-to-enable-disable-text-fields-using-jQUery.png 640w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/08\/How-to-enable-disable-text-fields-using-jQUery-300x158.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<p>That&#8217;s all about\u00a0<b>how to enable and disable an element using JavaScript and jQuery<\/b>. In this example, we have disabled the text field and re-enabled again but you can use this technique to enable\/disable any HTML element. You can use JavaScript or jQuery based upon what is used in your project. My suggestion is to be consistent. If you are already using JavaScript then use that, but if you are using jQuery then it&#8217;s better to do it as jQuery way.<\/p>\n<h2>Further Reading<\/h2>\n<p><a href=\"http:\/\/www.shareasale.com\/m-pr.cfm?merchantID=53701&amp;userID=880419&amp;productID=546412445\" target=\"_blank\" rel=\"nofollow noopener\">jQuery Fundamentals By Dan Wahlin<\/a><br \/>\n<a href=\"http:\/\/www.shareasale.com\/m-pr.cfm?merchantID=53701&amp;userID=880419&amp;productID=546412665\" target=\"_blank\" rel=\"nofollow noopener\">Advanced Techniques in JavaScript and jQuery By Kevin Murray<\/a><br \/>\n<a href=\"http:\/\/www.amazon.com\/dp\/1449393217\/?tag=javamysqlanta-20\" target=\"_blank\" rel=\"nofollow noopener\">Head First jQuery and JavaScript<\/a><\/p>\n<p>Other\u00a0<b>jQuery and JavaScript tutorials<\/b> you may like to explore<\/p>\n<ul>\n<li>Top 5 jQuery Books Every Web Developer Should Read? (see <a href=\"http:\/\/javarevisited.blogspot.sg\/2013\/07\/top-5-jquery-books-for-web-developers-learn.html\" target=\"_blank\" rel=\"noopener\">here<\/a>)<\/li>\n<li>How to get current URL Parameter using jQuery? (<a href=\"http:\/\/javarevisited.blogspot.sg\/2013\/06\/JQuery-JavaScript-tutorial-how-to-get-current-url-parameters-hashtag.html\" target=\"_blank\" rel=\"noopener\">solution<\/a>)<\/li>\n<li>How to use multiple jQuery Date picker element in one HTML page? (<a href=\"http:\/\/javarevisited.blogspot.sg\/2013\/10\/how-to-use-multiple-jquery-ui-date.html\" target=\"_blank\" rel=\"noopener\">answer<\/a>)<\/li>\n<li>10 Examples of jQuery selectors for Web Developers (<a href=\"http:\/\/www.java67.com\/2016\/09\/10-example-of-jquery-selectors-for-web.html\" target=\"_blank\" rel=\"noopener\">tutorial<\/a>)<\/li>\n<li>How to redirect web page using jQuery code? (<a href=\"http:\/\/javarevisited.blogspot.sg\/2013\/12\/how-to-redirect-page-or-url-jQuery-JavaScript-Example.html\" target=\"_blank\" rel=\"noopener\">answer<\/a>)<\/li>\n<li>3 Ways to parse HTML using JSoup in Java? (<a href=\"http:\/\/javarevisited.blogspot.sg\/2014\/09\/how-to-parse-html-file-in-java-jsoup-example.html\" target=\"_blank\" rel=\"noopener\">solution<\/a>)<\/li>\n<li>How to reload\/refresh a page using jQuery? (<a href=\"http:\/\/javarevisited.blogspot.sg\/2017\/07\/how-to-reload-refresh-page-using-JavaScript-jQuery.html\" target=\"_blank\" rel=\"noopener\">answer<\/a>)<\/li>\n<li>How to prevent double submission of POST data using JavaScript? (<a href=\"http:\/\/javarevisited.blogspot.sg\/2013\/02\/disable-submit-button-in-html-javascript-avoid-multiple-form-submission.html\" target=\"_blank\" rel=\"noopener\">solution<\/a>)<\/li>\n<li>How to modify multiple elements in one go in jQuery? (<a href=\"http:\/\/javarevisited.blogspot.sg\/2017\/05\/jquery-tutorial-how-to-modify-multiple-elements-in-one-line.html\" target=\"_blank\" rel=\"noopener\">example<\/a>)<\/li>\n<li>How to check and uncheck checkboxes using jQuery? (<a href=\"http:\/\/javarevisited.blogspot.sg\/2017\/07\/how-to-checkuncheck-checkbox-using-jQuery-example.html\" target=\"_blank\" rel=\"noopener\">tutorial<\/a>)<\/li>\n<\/ul>\n<p>Thanks for reading this article so far. If you like this article then please share with your friends and colleagues. If you have any question or doubt then please drop a comment.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/javarevisited.blogspot.com\/2017\/08\/how-to-enable-disable-element-using-jQuery-JavaScript-example.html\">How to enable\/disable an element using jQuery and JavaScript? Example<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Javin Paul at the <a href=\"http:\/\/javarevisited.blogspot.com\/\">Javarevisited<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes we need to enable and disable input elements e.g. text box, radio buttons or checkbox, how can we do it dynamically without loading the page? Well, we can use JavaScript, particularly jQuery to do this. An element can be disabled in HTML by setting disable property to true and enabled again by setting disabled=false. &hellip;<\/p>\n","protected":false},"author":62,"featured_media":927,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[82,63],"class_list":["post-18295","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development","tag-javascript","tag-jquery-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to enable\/disable an element using jQuery and JavaScript? Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Sometimes we need to enable and disable input elements e.g. text box, radio buttons or checkbox, how can we do it dynamically without loading the page?\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to enable\/disable an element using jQuery and JavaScript? Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Sometimes we need to enable and disable input elements e.g. text box, radio buttons or checkbox, how can we do it dynamically without loading the page?\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-18T09:15:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-08-18T13:52:15+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Javin Paul\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Javin Paul\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/\"},\"author\":{\"name\":\"Javin Paul\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/3212e35d6bfac3bca3961904a9e44bd7\"},\"headline\":\"How to enable\/disable an element using jQuery and JavaScript? Example\",\"datePublished\":\"2017-08-18T09:15:21+00:00\",\"dateModified\":\"2017-08-18T13:52:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/\"},\"wordCount\":874,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"keywords\":[\"javascript\",\"JQuery\"],\"articleSection\":[\"Web Dev\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/\",\"name\":\"How to enable\/disable an element using jQuery and JavaScript? Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"datePublished\":\"2017-08-18T09:15:21+00:00\",\"dateModified\":\"2017-08-18T13:52:15+00:00\",\"description\":\"Sometimes we need to enable and disable input elements e.g. text box, radio buttons or checkbox, how can we do it dynamically without loading the page?\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Web Dev\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/web-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to enable\/disable an element using jQuery and JavaScript? Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/3212e35d6bfac3bca3961904a9e44bd7\",\"name\":\"Javin Paul\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dc70a0e0b9d5c6614098936b017d6c79ed7f3e0c315a1e59d7d300e4c46d726c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dc70a0e0b9d5c6614098936b017d6c79ed7f3e0c315a1e59d7d300e4c46d726c?s=96&d=mm&r=g\",\"caption\":\"Javin Paul\"},\"sameAs\":[\"http:\/\/javarevisited.blogspot.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/javin-paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to enable\/disable an element using jQuery and JavaScript? Example - Web Code Geeks - 2026","description":"Sometimes we need to enable and disable input elements e.g. text box, radio buttons or checkbox, how can we do it dynamically without loading the page?","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/","og_locale":"en_US","og_type":"article","og_title":"How to enable\/disable an element using jQuery and JavaScript? Example - Web Code Geeks - 2026","og_description":"Sometimes we need to enable and disable input elements e.g. text box, radio buttons or checkbox, how can we do it dynamically without loading the page?","og_url":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-08-18T09:15:21+00:00","article_modified_time":"2017-08-18T13:52:15+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","type":"image\/jpeg"}],"author":"Javin Paul","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Javin Paul","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/"},"author":{"name":"Javin Paul","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/3212e35d6bfac3bca3961904a9e44bd7"},"headline":"How to enable\/disable an element using jQuery and JavaScript? Example","datePublished":"2017-08-18T09:15:21+00:00","dateModified":"2017-08-18T13:52:15+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/"},"wordCount":874,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","keywords":["javascript","JQuery"],"articleSection":["Web Dev"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/","url":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/","name":"How to enable\/disable an element using jQuery and JavaScript? Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","datePublished":"2017-08-18T09:15:21+00:00","dateModified":"2017-08-18T13:52:15+00:00","description":"Sometimes we need to enable and disable input elements e.g. text box, radio buttons or checkbox, how can we do it dynamically without loading the page?","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/web-dev-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/web-development\/enabledisable-element-using-jquery-javascript-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Web Dev","item":"https:\/\/www.webcodegeeks.com\/category\/web-development\/"},{"@type":"ListItem","position":3,"name":"How to enable\/disable an element using jQuery and JavaScript? Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/3212e35d6bfac3bca3961904a9e44bd7","name":"Javin Paul","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/dc70a0e0b9d5c6614098936b017d6c79ed7f3e0c315a1e59d7d300e4c46d726c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc70a0e0b9d5c6614098936b017d6c79ed7f3e0c315a1e59d7d300e4c46d726c?s=96&d=mm&r=g","caption":"Javin Paul"},"sameAs":["http:\/\/javarevisited.blogspot.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/javin-paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/18295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/62"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=18295"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/18295\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/927"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=18295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=18295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=18295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}