views:

174

answers:

2

I know practically nothing about jquery so please help me

I try this

function googlemapLinks {
 $('div.gmnoprint a').attr("href").replace('ll','q');
}

it does not work I have a <div class="gmnoprint"> In that div Google maps puts a javascript link in maps.google.com/maps?ll=5..... I need maps.google.com/maps?q=5.....

Can you show me a function I can drop in a script file?

+1  A: 

For setting a value with attr, you need to pass the new value as a second parameter. try this:

$('div.gmnoprint a').attr('href', $('div.gmnoprint a').attr('href').replace('ll','q'));
David Hedlund
+1  A: 

try this:

function googlemapLinks { 
    var lnk = $('div.gmnoprint a').attr("href");
    $('div.gmnoprint a').attr("href",lnk.replace('ll','q')); 
}
TheVillageIdiot
Thank you d and TheVillageIdiot. Looks very feasable but it's not working... maybe because it googlemap is written in by javascript already and not as html?Is it maybe possible to grab that url with ll in it and append it to text underneath and then replace with qfunction appendMap() { if ($('.block-gmap_location').length > 0) { $('.block-gmap_location').append($('<p>See this on <a href="url-from-googlemap">Google maps</a></p>')); }
kritter
if it's not working, it's probably because `$('div.gmnoprint a')` is empty at the time the code is executed. make sure that `googlemapLinks()` is called after the map has been shown, at a point when you're sure that it exists. try just typing out `javascript:alert($('div.gmnoprint a').length);` in your browser's address field, to make sure that the selector is working and returning any items at all
David Hedlund