2012-07-30 46 views
1

我搜索过的网页和StackOverflow的一个解决方案排除元素的Cufón改造,因为我的字体“BlueHighwayDType”这么想的包含“'符号,所以我必须排除这个元素才能在ie7/8上看到它。 http://www.matteowebdesigner.com/test/yesimove/的Cufón不选择排除的元素:没有

<!--head--> 
<!--[if lt IE 9]> 
<script type="text/javascript" src="js/cufon-yui.min.js"></script> 
<script type="text/javascript" src="js/Blue_Highway_D_Type_400.font.js"></script> 
<script type="text/javascript" src="js/mind-ie.js"></script> 
<![endif]--> 

,我想替换的元素是p和我想排除元素span.small

<!--body--> 
<article> 
    <p>L'unico <strong>Personal Trainer</strong> <br/> 
    che ti segue ovunque</p> 
    <p>e ti permette di <strong>condividere</strong> 
    i tuoi progressi con i tuoi amici.</p> 
    <p>A soli <strong>9.<span class="small">99 &euro;</span></strong> al mese !</p> 
</article> 

于是,我的例子,我在网络上找到我用选择器':不是',但它没有奏效。看看这个:

/*mind-ie.js*/ 
$(document).ready(function() { // Start Functions 
    Cufon.replace('#main #slogan section article p:not(.small)'); 
}); 

我不明白,因为它不工作,我认为选择是正确的。

回答

1

即使在这种情况下,排除所有span元素。

Cufon.replace('#main #slogan section article p',{ignore:{span:true}}); 
0

small类实际上是由<span>元素显示的,而不是由<p>元素显示。

尝试使用:has()选择:

Cufon.replace("#slogan section article p:not(:has(.small))"); 

关于第二个想法,这会忽略包含匹配.small元素,这可能不是你想要的<p>元素。指定ignoreClass选项看起来像一个更好的主意:

Cufon.replace("#slogan section article p", { 
    ignoreClass: "small" 
}); 
+0

我试过也是这样,但是它排除了所有第三段。然后我用这种方式尝试了'Cufon.exclude('#main #slogan section article p .small');'但结果不会改变。 – 2012-07-30 14:22:56

+0

我认为错误是选择最后所有'p',而我必须排除的元素只是标签'span'。 – 2012-07-31 12:35:55

+0

我认为这是因为Cufon转换了匹配元素的全部内容,包括后代,但不能排除这些后代。 'ignoreClass'和'exclude()'不工作似乎指向那个... – 2012-07-31 12:42:13