{"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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">jQuery Code<\/span> <\/div> <pre class=\"language-java code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-java code-embed-code\">$(&#039;element&#039;).removeClass(&#039;class1&#039;).removeClass(&#039;class2&#039;);<\/code><\/pre> <\/div>\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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">jQuery Code<\/span> <\/div> <pre class=\"language-java code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-java code-embed-code\">$(&quot;element&quot;).removeClass(&quot;class1 class2&quot;);<\/code><\/pre> <\/div>\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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">javascript code<\/span> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">$(&#039;element&#039;).removeClass(&#039;class1 class2&#039;);<\/code><\/pre> <\/div>\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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">jQuery Code<\/span> <\/div> <pre class=\"language-java code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-java code-embed-code\">$(&quot;p:odd&quot;).removeClass(&quot;blue under&quot;);<\/code><\/pre> <\/div>\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<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <span class=\"code-embed-name\">javascript Code<\/span> <\/div> <pre class=\"language-javascript code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-javascript code-embed-code\">$(&quot;button&quot;).click(function()<br\/>{<br\/>$(&quot;p&quot;).removeClass(&quot;intro&quot;);<br\/>}<\/code><\/pre> <\/div>\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: Can&#8217;t use removeClass(); as it would remove ALL classes, which we don&#8217;t want.1 SOLUTION 1: From removeClass(), the class parameter: One or more CSS classes to remove from the elements, these are separated by spaces. SOLUTION 2: This is one of the solution : [ad [&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}]}}