简体   繁体   English

单击时如何更改链接的颜色?

[英]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.

相关问题 单击链接时如何更改跨度颜色 - How can I make a span change color when a link is clicked 单击时如何更改链接按钮的颜色(访问的链接)? - How to change color of linkbutton when clicked(visited link)? 如何使用jQuery更改单击链接的颜色 - How to change the color of clicked link using jquery 如何在链接单击时更改div的颜色,然后单击其他链接时,另一个div更改颜色,上一个设置为默认颜色 - How to change color of div on link click and then when other link is clicked, another div changes color, previous is set to default color 单击时如何动态更改表单元格中的链接值时表格行的背景色 - how to dynamically change a table row background color when a link value within its cell changes when clicked HTML CSS - 单击时使图标更改颜色(如链接) - HTML CSS - Make icon change color when clicked (like a link) 单击内部链接时如何更改div背景颜色 - How do I Change div background color when link inside is clicked 单击td中的链接时,如何更改td的背景颜色? - How can I change the background color of a td when a link in the td is clicked? 如何将链接的颜色从黑色更改为红色,再次单击时将其更改为黑色 - How to change color of a link from black to red and back to black when clicked again 单击时以及单击其他按钮时如何更改按钮的颜色 - How to change the color of a button when clicked, and when other button is clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM