使用jquery填充带有href值的_link()目标网址 [英] Populate _link() target url with href value using jquery

查看:204
本文介绍了使用jquery填充带有href值的_link()目标网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得链接中href属性的值以使用jquery填充_link()目标url值?

How can I get the value of the href attribute in a link to populate the _link() target url value using jquery?

这是普通代码:

/ p>

This is the normal code:

<a href="http://www.mydomain.com/gallery/" onclick="_gaq.push(['_link', 'http://www.mydomain.com/gallery']); return false;">Gallery</a>

有很多链接需要以这种方式更新。

There are many links that need to be updated in this fashion.

推荐答案

你可以为你想运行 _gaq.push 的链接创建一个类,然后使用jQuery 将点击事件绑定到他们。

You can create a class for the links you would like to run _gaq.push for and then use jQuery live() to bind the click event to them.

给你的链接添加一个类,比如 gaq

Give your links a class like gaq:

<a class="gaq" href="http://www.mydomain.com/gallery/">Gallery</a>

并使用jQuery live()给予这个类的所有链接在点击时运行推送功能。

And use jQuery live() to give all links with this class the ability to run the push function on click.

$('.gaq').live('click', function() {
    _gaq.push(['_link', $(this).attr("href")]);
    return false;
});

这篇关于使用jquery填充带有href值的_link()目标网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆