Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove All classes From Div

Tags:

jquery

css

Is there any way to remove all classes from div ... on click of image. I want to remove all the classes from it.

Please Help,

$(document).ready(function () {     $("img").click(function(){         var pos=$('img', this).attr('alt');         alert('i am imageFlip'+this.alt);                     console.log('i am Image Flip');         var t = $(this);          t.prevAll().removeClass('lower').addClass('t1');         t.nextAll().removeClass('t1').addClass('t2');     }); }); 

Here in my code, I want to remove all classes from $(this).

like image 292
anam Avatar asked May 02 '13 07:05

anam


People also ask

How do I get rid of all classes?

To remove all classes, use the removeClass() method with no parameters. This will remove all of the item's classes.

How do you remove a class from a div?

Use the classList. remove() method to remove a class from a div element, e.g. box. classList. remove('my-class') .

How do I remove all CSS from a class?

To remove all CSS classes of an element, we use removeClass() method. The removeClass() method is used to remove one or more class names from the selected element.


2 Answers

http://api.jquery.com/removeClass/

If a class name is included as a parameter, then only that class will be removed from the set of matched elements. If no class names are specified in the parameter, all classes will be removed.

like image 129
Andy Avatar answered Oct 11 '22 06:10

Andy


You can use removeClass without using any class as a parameter.

Description: Remove a single class, multiple classes, or all classes from each element in the set of matched elements.

Like:

$(this).removeClass(); 
like image 39
Irvin Dominin Avatar answered Oct 11 '22 06:10

Irvin Dominin