Lucas Ariel Enrich Lucas Ariel Enrich - 7 months ago 8
Javascript Question

How to remove a class on click event?

this is the html:

`





Prueba





</body>
</html> `


this the css:

.prueba{
height: 100px;
width: 100px;
background-color: green;
}

and this the js (EDITED):
`

var main=function(){
$('.prueba').click(function(){
$(this).removeClass('.prueba');
});

};

$(document).ready(main);


`

It (STILL) doesn't work. Can someone help me?

Answer

To select class, you should preface class name with a dot:

$('.prueba')

JQuery docs you may want to review.

Comments