anam anam - 4 months ago 46
jQuery Question

Remove All classes From Div

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).

Thanks and Regards,

Answer

You don't need to wrap this in a jQuery selector to complete this job.

To remove all classes from the element

this.className = '';