0

我想在单击时更改链接颜色,链接是基于 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>

我怎样才能做到这一点?提前致谢

4

4 回答 4

1

如果是 AJAX 链接,则不能使用:visited伪选择器。

相反,使用:

 $('a').live('click',function(){this.style.css.color='red'})

或类似的东西

于 2013-02-25T08:00:37.560 回答
1

尝试

$('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
});
于 2013-02-25T08:00:50.763 回答
0

应该是这样的

 $('a').on('click',function(){
     $(this).css('color','red');
 });
于 2013-02-25T08:03:55.520 回答
0

在现代浏览器中(甚至在 IE10 中),如果您设置a:active伪类,您将在没有 JavaScript 的情况下得到以下结果:

a:active{ color: red; }

您还可以分配其他属性。

于 2013-02-25T10:44:08.687 回答