{"id":2144,"date":"2017-03-24T19:11:58","date_gmt":"2017-03-24T13:41:58","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=2144"},"modified":"2017-03-28T16:24:03","modified_gmt":"2017-03-28T10:54:03","slug":"removing-multiple-classes-jquery","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/removing-multiple-classes-jquery\/","title":{"rendered":"[ Solved -5 Answers ] JAVA &#8211; Removing multiple classes (jQuery)"},"content":{"rendered":"<p><label class=\"label label-Warning\">PROBLEM :<\/label><\/p>\n<ul>\n<li>Is there any better way to rewrite this:<\/li>\n<\/ul>\n[pastacode lang=&#8221;java&#8221; manual=&#8221;%24(&#8216;element&#8217;).removeClass(&#8216;class1&#8217;).removeClass(&#8216;class2&#8217;)%3B&#8221; message=&#8221;jQuery Code&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]\n<ul>\n<li>Can&#8217;t use removeClass(); as it would remove ALL classes, which we don&#8217;t want.1<\/li>\n<\/ul>\n<p><label class=\"label label-info\">SOLUTION 1:<\/label><\/p>\n[pastacode lang=&#8221;java&#8221; manual=&#8221;%24(%22element%22).removeClass(%22class1%20class2%22)%3B&#8221; message=&#8221;jQuery Code&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]\n<ul>\n<li>From removeClass(), the class parameter:<\/li>\n<li>One or more CSS classes to remove from the elements, these are separated by spaces.<\/li>\n<\/ul>\n<p><label class=\"label label-info\">SOLUTION 2:<\/label><\/p>\n<ul>\n<li>This is one of the solution :<\/li>\n<\/ul>\n[pastacode lang=&#8221;javascript&#8221; manual=&#8221;%24(&#8216;element&#8217;).removeClass(&#8216;class1%20class2&#8217;)%3B%0A&#8221; message=&#8221;javascript code&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]\n[ad type=&#8221;banner&#8221;]\n<p><label class=\"label label-info\">SOLUTION 3:<\/label><\/p>\n<ul>\n<li>One or more CSS classes to remove from the elements, these are separated by spaces.<\/li>\n<\/ul>\n<p><label class=\"label label-info\">SOLUTION 4:<\/label><\/p>\n<h4 id=\"we-can-do-this\"><span style=\"color: #808000;\"><strong>We can do this :<\/strong><\/span><\/h4>\n<ul>\n<li>class (Optional) String<\/li>\n<li>One or more CSS classes to remove from the elements, these are separated by spaces.<\/li>\n<\/ul>\n<h4 id=\"example\"><span style=\"color: #800080;\"><strong>Example:<\/strong><\/span><\/h4>\n<ul>\n<li>Remove the class &#8216;blue&#8217; and &#8216;under&#8217; from the matched elements.<\/li>\n<\/ul>\n[pastacode lang=&#8221;java&#8221; manual=&#8221;%24(%22p%3Aodd%22).removeClass(%22blue%20under%22)%3B&#8221; message=&#8221;jQuery Code&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]\n<p><label class=\"label label-info\">SOLUTION 5:<\/label><\/p>\n<ul>\n<li><span style=\"color: #333300;\">Remove the class name &#8220;intro&#8221; from all ements:<\/span><\/li>\n<\/ul>\n[pastacode lang=&#8221;javascript&#8221; manual=&#8221;%24(%22button%22).click(function()%0A%7B%0A%24(%22p%22).removeClass(%22intro%22)%3B%0A%7D&#8221; message=&#8221;javascript Code&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/]\n<p style=\"top: 93px;\">[ad type=&#8221;banner&#8221;]\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PROBLEM : Is there any better way to rewrite this: [pastacode lang=&#8221;java&#8221; manual=&#8221;%24(&#8216;element&#8217;).removeClass(&#8216;class1&#8217;).removeClass(&#8216;class2&#8217;)%3B&#8221; message=&#8221;jQuery Code&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/] Can&#8217;t use removeClass(); as it would remove ALL classes, which we don&#8217;t want.1 SOLUTION 1: [pastacode lang=&#8221;java&#8221; manual=&#8221;%24(%22element%22).removeClass(%22class1%20class2%22)%3B&#8221; message=&#8221;jQuery Code&#8221; highlight=&#8221;&#8221; provider=&#8221;manual&#8221;\/] From removeClass(), the class parameter: One or more CSS classes to remove from the elements, these [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2139],"tags":[3755,4581,4576,4582,4575,4584,4577,4583,4586,4589,4587,4578,4588,4585,4590,4579,4580],"class_list":["post-2144","post","type-post","status-publish","format-standard","hentry","category-java","tag-removeclass","tag-add-remove-classes-with-javascript-property-classlist","tag-css-removing-multiple-classes-jquery","tag-element-classlist","tag-javascript-add-and-remove-multiple-classes-in-jquery","tag-jquery-add-multiple-classes","tag-jquery-multiple-classes-selector","tag-jquery-remove-all-classes-except","tag-jquery-remove-class-not-working","tag-jquery-remove-class-wildcard","tag-jquery-remove-multiple-elements","tag-jquery-removeclass-method","tag-jquery-replace-class","tag-remove-class-javascript","tag-remove-id-jquery","tag-remove-multiple-classes-using-removeclass","tag-removeclass-not-removing-multiple-classes-at-once"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/2144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=2144"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/2144\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=2144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=2144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=2144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}