I have a div, with a specific class.
When one clicks the div, I want its class to change to a something else.
Is it because there is no .class
or .parent
.
$(".mapexpand").click(function() {
$(this).parent().class('.mapcollapse');
});
I have a div, with a specific class.
When one clicks the div, I want its class to change to a something else.
Is it because there is no .class
or .parent
.
$(".mapexpand").click(function() {
$(this).parent().class('.mapcollapse');
});
$(".mapexpand").click(function() {
$(this).attr('class', 'mapcollapse');
});
$(".mapexpand").click(function() {
$(this).attr('class', 'mapcollapse');
})
$(".mapexpand").click(function() {
$(this).parent().removeClass().addClass('mapcollapse');
});
$(".mapexpand").click(function() {
$(this).parent().toggleClass('mapcollapse');
});
Use addClass and removeClass functions
$(".mapexpand").click(function() {
$(this).removeClass("mapexpand").addClass("newClass");
});
This one removes your current class and adds a new one
In response to your comments above, here is the correct function.
$(".mapexpand").click(function() {
$(this).attr('class', 'mapcollapse');
if($(this).type()=="div") {
// do more stuff
}
});