English 中文(简体)
添加案文,以结束含有某种内容的所有链接
原标题:add text to end of all links containing something
  • 时间:2011-01-06 20:59:07
  •  标签:
  • jquery

I m trying to add to the end of specific links that contain a certain text.

在我的法典中,我发现了具体的联系,并改变了这些联系的开始,留下了原始链接的变数。 我需要在这一变量的末尾增加。 目前,我使用的是背信标,但只是把案文与实际联系联系起来。 我怎么能够这样做,或者做得更好?

$(document).ready(function () {

    $("a[href^= http://www.1shoppingcart.com/ ]").each(function () {
        this.href = this.href.replace(/^http://www.1shoppingcart.com/SecureCart/SecureCart.aspx/,
         "http://www.1shoppingcart.com/SecureCart/Securecart.aspx/onclick =  _gaq.push([ _link ,  http://www.1shoppingcart.com/SecureCart/Securecart.aspx/");
    });
    $( a[href*=1shoppingcart] ).append(" ]); return false; ");
});
最佳回答
$( a[href*=1shoppingcart] ).attr( href , function(i,v) {
    return v +  ]); return false; ;
});
问题回答

You could do it with another each call:

$( a[href*=1shoppingcart] ).each(function () {
  this.href = this.href +  ]); return false; ;
}

尽管如此,你真的需要这样做吗? 它希望你重新添加谷歌分析点,似乎只需增加一个<条码>click即可。 各位联系人(而不是修改<代码>href属性)。





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签