Cufon - jQuery,点击时替换字体颜色
我使用 cufon 进行一些字体替换,并使用 jQuery 构建自定义手风琴。
我的手风琴的代码是这样的:
$(".acc-title").click(function () {
//show something, hide something etc.
});
在单击事件期间是否可以更改替换(使用 cufon)字体的颜色?
像这样的东西:
$(".acc-title").click(function () {
//some something, hide something etc.
Cufon.replace('how do i select ONLY the title of this', { color: '#fff' });
});
I am using cufon for some font replacement and jQuery to build a custom accordion.
the code for my accordion is something like this:
$(".acc-title").click(function () {
//show something, hide something etc.
});
Is it possible during the click event to change the color of the replaced (with cufon) font?
something like:
$(".acc-title").click(function () {
//some something, hide something etc.
Cufon.replace('how do i select ONLY the title of this', { color: '#fff' });
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须使用 Cufon.refresh();通过CSS改变颜色后。像这样:
You must use Cufon.refresh(); after you change the color by CSS. Like this:
我会考虑使用 CSS 类,而不是通过 css 函数更改颜色
尽管如此,如果您想要显示/隐藏:
如果 acc-title 是您正在操作的内容,那么以下内容就足够了:
您也可以通过将上面的 acc-title 选择器与父元素的 ID 相结合来加速它。
或者给该项目一个ID itslef:
或者,你的h2(不过,这有点慢):
所以,总而言之,你的答案可能看起来像这样:
但我猜测了一下,因为我不完全确定你是什么正在追随
I would be looking at using a CSS class instead of changing the colour through the css function
Although, if you are looking to show/hide:
If acc-title is the thing you are operating on, then the following will suffice:
You could also speed the above acc-title selector by combining it with the ID of a parent element.
Or give the item an ID itslef:
Or, your h2 (this is a little slower, though):
So, to summarise, your answer might look something like:
But I'm guessing a bit as I'm not entirely sure what you're after