Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.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修改href的值_Jquery_Css_Xhtml - Fatal编程技术网

jquery修改href的值

jquery修改href的值,jquery,css,xhtml,Jquery,Css,Xhtml,我有很多类.moo的链接,我需要jquery扫描元素以查找它们,然后在href的末尾添加一点文本 例如: 这就是我所拥有的: <a href="http://root.net" class="moo">root.net</a> 这就是我想要的,在jQuery魔术发生之后: <a href="http://root.net?iframe=true&amp;width=600&amp;height=300e" class="moo">root

我有很多类
.moo
的链接,我需要jquery扫描元素以查找它们,然后在href的末尾添加一点文本

例如:

这就是我所拥有的:

<a href="http://root.net" class="moo">root.net</a>

这就是我想要的,在jQuery魔术发生之后:

<a href="http://root.net?iframe=true&amp;width=600&amp;height=300e" class="moo">root.net</a>

我需要它的原因是一个jquery插件,它接受以下内容:
?iframe=true&;宽度=600&;高度=300

这能做到吗?我是一个jquerynoob,我一直在摆弄prepend等等,但我还是不明白

谢谢。

这不管用吗

$('.moo').attr('href','')

这不管用吗

$('.moo').attr('href','')

我想那应该行

$(function(){
    $(".moo").each(function(){
        $(this).attr("href", $(this).attr("href") + "?iframe=true&amp;width=600&amp;height=300");
    });
});

这应该行得通,我想如果你不知道你的基本url会是什么,这会更好。嘿,我们在同一时间用同样的答案回答了这个问题。我看到-这就是低挂果实的情况:)如果你不知道你的基本url会是什么,这会更好。嘿,我们在同一时间用同样的答案回答了这个问题,我看到了——低垂的果实就是这样的:)
$(function(){
    $(".moo").each(function(){
        $(this).attr("href", $(this).attr("href") + "?iframe=true&amp;width=600&amp;height=300");
    });
});