Ste*_*eve 10 css anchor jquery jquery-selectors
好的,这听起来很简单,使用jquery的'click'功能.
问题是我想要链接的原始颜色而不是其悬停的颜色 - 例如,如果链接是绿色且悬停状态为橙色,我会抓住绿色.
我尽力而为,并在小提琴中表现出来
有人有任何想法吗?
编辑:道歉,但随着一些鹰眼发现(感谢他们指出)绿色实际上是"rgb(0,128,0)",而不是rgb(0,255,0),如我原来所示小提琴.
Jos*_*ber 14
将其存储在jQuery的data对象中:
$('a').each(function() {
$(this).data('color', $(this).css('color') );
})
.click(function() {
alert( $(this).data('color') );
});
Run Code Online (Sandbox Code Playgroud)
这是你的小提琴:http://jsfiddle.net/sVDYe/4/
$('a').each(function() {
$.data(this, 'color', $.css(this, 'color') );
});
Run Code Online (Sandbox Code Playgroud)
这是小提琴:http://jsfiddle.net/sVDYe/13/