since jQuery 1.4 removeClass();
now takes a function as argument.
My <body>
tag has a few classes added to it, for example:
<body class="heading-helvetica para-georgia pattern-flowers">
I wish to be able to replace the classnames, and I believe the function in removeClass()
can help me, but I don't really understand the documentation on the jQuery site nor am I any good with Regex.
How can I replace for example heading-helvetica
with heading-myriad
or para-georgia
with para-times
and so on?
I had previously used something like this, which works only if the class name it is trying to replace is the first in the list of class names:
$('#headings li').click(function(){
var this_class = $(this).attr('id');
$('body[class|="heading"]').removeClass();
$('body').addClass(this_class);
});