{"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=\u201djava\u201d manual=\u201d%24(\u2018element\u2019).removeClass(\u2018class1\u2019).removeClass(\u2018class2\u2019)%3B\u201d message=\u201djQuery Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<ul>\n<li>Can\u2019t use removeClass(); as it would remove ALL classes, which we don\u2019t want.1<\/li>\n<\/ul>\n<p><label class=\"label label-info\">SOLUTION 1:<\/label><\/p>\n[pastacode lang=\u201djava\u201d manual=\u201d%24(%22element%22).removeClass(%22class1%20class2%22)%3B\u201d message=\u201djQuery Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\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=\u201djavascript\u201d manual=\u201d%24(\u2018element\u2019).removeClass(\u2018class1%20class2\u2019)%3B%0A\u201d message=\u201djavascript code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\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 \u2018blue\u2019 and \u2018under\u2019 from the matched elements.<\/li>\n<\/ul>\n[pastacode lang=\u201djava\u201d manual=\u201d%24(%22p%3Aodd%22).removeClass(%22blue%20under%22)%3B\u201d message=\u201djQuery Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p><label class=\"label label-info\">SOLUTION 5:<\/label><\/p>\n<ul>\n<li><span style=\"color: #333300;\">Remove the class name \u201cintro\u201d from all ements:<\/span><\/li>\n<\/ul>\n[pastacode lang=\u201djavascript\u201d manual=\u201d%24(%22button%22).click(function()%0A%7B%0A%24(%22p%22).removeClass(%22intro%22)%3B%0A%7D\u201d message=\u201djavascript Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p style=\"top: 93px;\">[ad type=\u201dbanner\u201d]\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PROBLEM : Is there any better way to rewrite this: [pastacode lang=\u201djava\u201d manual=\u201d%24(\u2018element\u2019).removeClass(\u2018class1\u2019).removeClass(\u2018class2\u2019)%3B\u201d message=\u201djQuery Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/] Can\u2019t use removeClass(); as it would remove ALL classes, which we don\u2019t want.1 SOLUTION 1: [pastacode lang=\u201djava\u201d manual=\u201d%24(%22element%22).removeClass(%22class1%20class2%22)%3B\u201d message=\u201djQuery Code\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/] 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}]}}