Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 覆盖锚点';s href_Jquery - Fatal编程技术网

Jquery 覆盖锚点';s href

Jquery 覆盖锚点';s href,jquery,Jquery,可能重复: 我有一个锚定标签,href=”“如是 。我想使用jQuery覆盖它,并提供一个不同的href。是否可以覆盖锚定标记的内联href 提前谢谢 $('.SwitchAccountLink').attr('href', 'http://www.google.com'); 您可以通过$(“.SwitchAccountLink”).attr('href','myNewHref')更改它您可以使用jqueryattr()来获取和设置元素属性的值,更多关于锚点标记具有类的信息,我们将使用类来唯

可能重复:

我有一个锚定标签,href=”“如是
。我想使用jQuery覆盖它,并提供一个不同的href。是否可以覆盖锚定标记的内联href

提前谢谢

$('.SwitchAccountLink').attr('href', 'http://www.google.com');

您可以通过
$(“.SwitchAccountLink”).attr('href','myNewHref')更改它

您可以使用jquery
attr()
来获取和设置元素属性的值,更多关于锚点标记具有类的信息,我们将使用类来唯一标识所有锚点
SwitchAccountLink

$('.SwitchAccountLink').attr('href', 'Yourhref');
当然可以,试试:

$('.SwitchAccountLink').attr('href','someurl');
可以使用函数修改元素的特定属性

$("a.SwitchAccountLink").attr('href',NEW_URL);
此代码将用
SwitchAccountLink
class替换所有锚定标记,并使用
NEW\u URL


如果您只想更改特定链接,则可能必须提供一个更独特的
id
属性或一个将所有链接分组的附加类。

@undefined-忘记再次初始化用户名?;)