tags:

views:

86

answers:

3

Hey,

I have a lot of links with the class .moo, I need jquery to scan the element for them, then to add a bit of text to the end of the href.

For example:

This is what I have:

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

and this is what I would like to have, after the jQuery magic happens:

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

The reason I need this is a jquery plugin that eats this: ?iframe=true&amp;width=600&amp;height=300.

Can this be done? I'm a jquery noob and I've been fiddling with prepend, etc, but I still don't get it.

Thanks.

A: 

Did this not work?

$('.moo').attr('href', 'http://root.net?iframe=true&amp;width=600&amp;height=300e');

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

that should work I think

Slee
this will work better if you do not know what your base url will be.
Slee
heh, we answered this at the exact same time with the same answer
T B
I saw that - that's what happens with the low hanging fruit :)
Slee
I kinda expected at least a few lines... thank you so much, it's so simple...
Kirill
+1  A: 
$(function(){
    $(".moo").each(function(){
        $(this).attr("href", $(this).attr("href") + "?iframe=true&amp;width=600&amp;height=300");
    });
});
T B