由于 jQuery 1.4removeClass();
现在将函数作为参数。
我的<body>
标签添加了一些类,例如:
<body class="heading-helvetica para-georgia pattern-flowers">
我希望能够替换类名,并且我相信函数removeClass()
可以帮助我,但我并不真正了解jQuery 站点上的文档,我对 Regex 也没有任何好处。
例如,我如何heading-helvetica
用heading-myriad
或para-georgia
用para-times
等替换?
我以前使用过类似的东西,只有当它试图替换的类名是类名列表中的第一个时才有效:
$('#headings li').click(function(){
var this_class = $(this).attr('id');
$('body[class|="heading"]').removeClass();
$('body').addClass(this_class);
});