我正在尝试使用带有dblclick()的jQuery更改字体Awesome图标颜色。基本上我想在用户双击图标时更改颜色,但它会给我一个错误
HTML
<body>
<div class ="contain">
<div id ="pic">
<img src ="https://www.w3schools.com/css/img_fjords.jpg"/>
</div>
<div id="desc">
<div id="img-row">
<i class="fa fa-heart-o" aria-hidden="true"></i>
</div>
<p><!---- some text ---></p>
</div>
</div>
</body>
的Javascript
$(document).ready(function(event){
$('.fa fa-heart-o').dblclick(css("color", "red"));
});
非常感谢任何帮助。
答案 0 :(得分:0)
您需要为dblclick事件提供处理函数。在处理程序函数中,您可以使用abstract class AbsIterator {
type T
def hasNext:Boolean
def next():T
}
class StringIterator(s:String) extends AbsIterator {
type T = Char
private var i = 0
def hasNext = i < s.length
def next()={
val ch = s charAt i
i += 1
ch
}
}
trait RichIterator extends AbsIterator {
def foreach (f:T => Unit):Unit = while(hasNext) f(next())
}
class Iter extends StringIterator ("This is a test") with RichIterator
val iter = new Iter
iter foreach println
来更改单击元素的颜色。像这样的东西:
this
答案 1 :(得分:0)
您的dblClick是正确的,但之后它正在寻找函数调用。您可以在https://api.jquery.com/dblclick/
了解更多信息 $(document).ready(function(event){
$('.fa fa-heart-o').dblclick(function(){
$(this).css("color", "red");
});
});