[英]how to change the color of link when clicked?
我想改變鏈接顏色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>
我怎樣才能做到這一點? 提前致謝
如果它是AJAX鏈接,則不能使用:visited
偽選擇器。
相反,使用:
$('a').live('click',function(){this.style.css.color='red'})
或類似的東西
嘗試
$('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
});
應該是這樣的
$('a').on('click',function(){
$(this).css('color','red');
});
在現代瀏覽器中(即使在IE10中)如果您將設置a:active
偽類您將在沒有JavaScript的情況下獲得此結果:
a:active{ color: red; }
您還可以指定其他屬性。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.