{"id":3126,"date":"2013-03-17T05:45:40","date_gmt":"2013-03-17T05:45:40","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=3126"},"modified":"2013-03-17T05:45:40","modified_gmt":"2013-03-17T05:45:40","slug":"jquery-remove-specific-class-examples-demos","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-remove-specific-class-examples-demos\/","title":{"rendered":"jQuery Remove Specific Class Examples \/  Demos"},"content":{"rendered":"<p>If you wish to use <em><strong>jQuery to remove specific class of an element<\/strong><\/em> on a web page, we can use the .removeClass() method. In this article, I am going to share easy way to delete the specific class(es) from different elements of a web page, such as Textbox, Textarea, Select Dropdown, Image, etc.<\/p>\n<p><!--more--><\/p>\n<h2>How to use jQuery to Remove Specific Class<\/h2>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=3126\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<p>Let&#8217;s assume that we have different html elements on a web page such as div, image, textbox, textarea, etc. We will see how to\u00a0delete\u00a0the specific class(es) when a button is clicked. So here we go:<\/p>\n<p><strong>Here is the basic common HTML source code for all the following examples:<\/strong><\/p>\n<pre class=\"lang:xhtml decode:true\" title=\"Common HTML source code for all the following examples:\">&lt;style type=\"text\/css\"&gt;\n.first_name {\n\tbackground-color: #FFFF99;\n\tborder: 1px solid #AEAE00;\n}\n.message {\n\tbackground-color: #9999FF;\n\tborder: 1px solid #90F;\n}\n.subscribe {\n\tbackground-color: #D7FFD7;\n\tborder: 1px solid #090;\n}\n.update {\n\tbackground-color: #E1F3FF;\n\tborder: 1px solid #09F;\n}\n.states {\n\tcolor: #D70000;\n\tfont-weight: bold;\n}\n.my_div {\n\tborder: 10px solid #C3C;\n\tbackground-color: #C9C;\n}\n.image_border {\n\tborder: 1px solid #CCC;\n\tpadding: 5px;\n}\n.blue_text {\n\tcolor: #06F;\t\n}\n.redborder {\n\tborder: 1px solid #F00;\t\n}\n.thick_border {\n\tborder: 10px solid #F00;\t\t\n}\n.orange_border {\n\tborder: 10px solid #F90;\n}\n.img_bottom_thick_border {\n\tborder-bottom-width: 10px;\n\tborder-bottom-style: solid;\n\tborder-bottom-color: #3C9;\t\n}\n.width_and_height {\n\twidth: 200px;\n\theight: 200px;\n}\n&lt;\/style&gt;\n\n  &lt;p&gt;\n    &lt;label for=\"first_name\"&gt;First Name&lt;\/label&gt;\n    &lt;input type=\"text\" name=\"first_name\" id=\"first_name\" class=\"first_name blue_text redborder\"&gt;\n    &lt;input type=\"submit\" name=\"sbt_remove1\" id=\"sbt_remove1\" value=\"Remove Red Border from Textbox\"&gt;\n  &lt;\/p&gt;\n  &lt;p&gt;\n    &lt;label for=\"message\"&gt;Message&lt;\/label&gt;\n    &lt;input type=\"submit\" name=\"sbt_remove2\" id=\"sbt_remove2\" value=\"Remove Thick Border from Textarea\"&gt;\n    &lt;br&gt;\n    &lt;textarea name=\"message\" id=\"message\" cols=\"45\" rows=\"5\" class=\"message thick_border\"&gt;&lt;\/textarea&gt;\n  &lt;\/p&gt;\n  &lt;p&gt;\n    &lt;label for=\"states\"&gt;States&lt;\/label&gt;\n    &lt;select name=\"states\" id=\"states\" class=\"states orange_border\"&gt;\n      &lt;option value=\"TX\" selected=\"selected\"&gt;TX&lt;\/option&gt;\n      &lt;option value=\"AL\"&gt;AL&lt;\/option&gt;\n      &lt;option value=\"CA\"&gt;CA&lt;\/option&gt;\n    &lt;\/select&gt;\n    &lt;input type=\"submit\" name=\"sbt_remove3\" id=\"sbt_remove3\" value=\"Remove Orange Border from Select Dropdown\"&gt;\n  &lt;\/p&gt;\n\n  &lt;p&gt;\n  &lt;img src=\"images\/money.jpg\" id=\"image_border\" class=\"image_border img_bottom_thick_border\" \/&gt;\n  &lt;input type=\"submit\" name=\"sbt_remove4\" id=\"sbt_remove4\" value=\"Remove Bottom Border from Image\"&gt;  \n  &lt;\/p&gt;\n\n  &lt;div id=\"my_div\" class=\"my_div width_and_height\"&gt;This is MY DIV&lt;\/div&gt;\n  &lt;input type=\"submit\" name=\"sbt_remove5\" id=\"sbt_remove5\" value=\"Remove Width and Height from Div\"&gt;<\/pre>\n<h3>Example 1: Removing a specific class from Textbox in jQuery using Textbox ID<\/h3>\n<pre class=\"lang:xhtml decode:true\" title=\"Example 1\">\t$('#sbt_remove1').on(\"click\", function(e){\t\t\n\n\t\t$('#first_name').removeClass('redborder');\n\n\t\te.preventDefault();\n\n\t});<\/pre>\n<h3>Example 2: Removing a specific class from Textarea in jQuery using Textarea ID<\/h3>\n<pre class=\"lang:xhtml decode:true\" title=\"Example 2\">\t$('#sbt_remove2').on(\"click\", function(e){\t\t\n\n\t\t$('#message').removeClass('thick_border');\n\n\t\te.preventDefault();\n\n\t});<\/pre>\n<h3>Example 3: Removing a specific class from Select Dropdown in jQuery using Select Dropdown ID<\/h3>\n<pre class=\"lang:xhtml decode:true\" title=\"Example 3\">\t$('#sbt_remove3').on(\"click\", function(e){\t\t\n\n\t\t$('#states').removeClass('orange_border');\n\n\t\te.preventDefault();\n\n\t});<\/pre>\n<h3>Example 4: Erasing a specific class from Image in jQuery using Image ID<\/h3>\n<pre class=\"lang:xhtml decode:true\" title=\"Example 4\">\t$('#sbt_remove4').on(\"click\", function(e){\t\t\n\n\t\t$('#image_border').removeClass('img_bottom_thick_border');\n\n\t\te.preventDefault();\n\n\t});<\/pre>\n<h3>Example 5: Deleting a specific class from Div in jQuery using Div ID<\/h3>\n<pre class=\"lang:xhtml decode:true\" title=\"Example 5\">\t$('#sbt_remove5').on(\"click\", function(e){\t\t\n\n\t\t$('#my_div').removeClass('width_and_height');\n\n\t\te.preventDefault();\n\n\t});<\/pre>\n<div class=\"make_demo\">\r\n\r\n\t<form action=\"https:\/\/theextremewebdesigns.com\/blog\/wp-content\/themes\/ewd_blog_2017\/try_demo.php?post_id=3126\" method=\"post\" name=\"form1\" target=\"_blank\" id=\"form1\">\r\n\r\n\r\n\t<input type=\"hidden\" name=\"shortcode_content\" id=\"shortcode_content\" value=\"\" \/>\r\n\r\n        <div class=\"try_demo_btn_container\">\r\n\r\n\r\n            <button type=\"submit\" name=\"sbt_make_demo\" id=\"sbt_make_demo\" class=\"btn-primary btn-try-demo\">\r\n                Try Demo\r\n            <\/button>\r\n\r\n\r\n        <\/div><!-- .try_demo_btn_container -->\r\n\r\n    <\/form>\r\n    <\/div>\r\n    \n<h4>That&#8217;s it!<\/h4>\n<p>Do you know of any other ways to use\u00a0<em><strong>jQuery to remove specific class<\/strong><\/em>? Feel free to suggest by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you wish to use jQuery to remove specific class of an element on a web page, we can use the .removeClass() method. In this article, I am going to share easy way to delete the specific class(es) from different elements of a web page, such as Textbox, Textarea, Select Dropdown, Image, etc.<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[20,13],"tags":[42,148,43,41],"class_list":["post-3126","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery-tips-and-tricks","category-tips-and-tricks","tag-jquery-demos-2","tag-jquery-remove-specific-class","tag-jquery-snippets","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-Oq","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/3126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=3126"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/3126\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=3126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=3126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=3126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}