9

我目前在我们的网站上使用类似于Cufon.set('fontFamily', 'DIN Medium').replace('h1');Now 的 Cufon 用于单个 H1 标签,我希望禁用 Cufon,这不会将 H1 标签更改为任何其他标签,它必须保持原样。

如果需要,我可以将类等添加到 H1 标记,并且可以执行任何 HTML/CSS/JS 而不更改实际标记。

任何人都知道这是否可能以及是否可行?

提前致谢,

沙迪

4

4 回答 4

11

根据您使用的选择器引擎,您可以:

  • 向您的异常 h1 元素添加一个类
  • 您可以使用 :not 选择器仅将 cufon 应用于没有上述类的 h1(使用 jQuery 和 classname 'clean' 它会像Cufon.replace('h1:not(.clean)');
于 2010-04-29T21:07:51.757 回答
3
function remove_cufon(selector) {
    $(selector).html( cufon_text(selector) );
    return true;
}

function cufon_text(selector) {
    var g = '';
    $(selector +' cufon cufontext').each(function() {
        g = g + $(this).html();
    }); 
    return $.trim(g);
}

用法:

remove_cufon('#name');
于 2011-02-17T21:26:56.117 回答
1

使用 jQuery:对 h1 使用 css 类并在选择器中指定...

$('h1.noCufon').each(function(){
        var cufonText = '';
        $('cufontext',$(this)).each(function(){
            cufonText+=$(this).html();
        });
    if(cufonText!=''){
        $(this).html(cufonText);
    }
})
于 2012-06-28T06:51:51.800 回答
0

你的意思是单h1?

$('h1').each(function(){
    if($(this).siblings('h1').length)
        Cufon.set('fontFamily', 'DIN Medium').replace(this);
});
于 2010-04-29T14:58:45.757 回答