[英]how to change the color of link when clicked?
I want to change the link colour onclick, the links are ajax based, i tried a lot but didn't get success how can i change the change it, request action is going on this page. 我想改变链接颜色onclick,链接是基于ajax,我尝试了很多,但没有成功我怎么能改变它,请求行动在这个页面上。
<div class="topheading-right">
<span>
<?php echo $this->Manager->link('Archived Events', array('a'));?>
</span>
<?php echo $this->Manager->link('View All', array(''));?>
</div>
</div>
<div id='events-event_list' class='dashboard-<?php echo __l($product_name);?>s'>
<?php echo $this->requestAction(array('controller'=>'events', 'action'=>'view_event_list', $is_archive), array('return'));?>
</div>
How can i do that? 我怎样才能做到这一点? thanks in advance
提前致谢
If it's an AJAX link, you can't use the :visited
pseudoselector. 如果它是AJAX链接,则不能使用
:visited
伪选择器。
Instead, use: 相反,使用:
$('a').live('click',function(){this.style.css.color='red'})
or something similar 或类似的东西
Try 尝试
$('a[id^="link-"]').on('click',function(event){
event.preventDefault();
var Obj = $(this);
Obj.css('color','red');
var href = Obj.attr('href');
//ajax call with url href
});
should be something like this 应该是这样的
$('a').on('click',function(){
$(this).css('color','red');
});
In modern browsers (even in IE10) if You will set a:active
pseudo class You will get this result without JavaScript: 在现代浏览器中(即使在IE10中)如果您将设置
a:active
伪类您将在没有JavaScript的情况下获得此结果:
a:active{ color: red; }
You can also asign othere attributes. 您还可以指定其他属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.