Pergunta

I have a question about accessing attributes using the jQuery .attr() function. I read a similar question here about escaping the colon using // like so:

$(".likebtn fb\\:like").hide();

However, this doesn't seem to affect the like button at all. I need to be able to access the href attribute of the fb:like tag to change the url every time a user clicks on a new picture:

$(".likebtn fb\\:like").attr('href', link);

The entire thing in context:

function displayFullImage(link)
{

    $("#currentlystaged").attr('src', link);
    $(".likebtn fb\\:like").attr('href', link);
}

This function is called when a user clicks on a thumbnail. WORKING LINK: http://www.rjwcollective.com/equinox/rishi_gallery/eqgall.php

Foi útil?

Solução

Your code DOES change the like button's src and href. The only problem is that this has no effect (as you noticed) because the like button is ALREADY rendered, and what's inside it is an iframe with the following src:

http://www.facebook.com/plugins/like.php?api_key=141637562574924&channel_url=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%3Fversion%3D0%23cb%3Df34a2a3b5%26origin%3Dhttp%253A%252F%252Fwww.rjwcollective.com%252Ff1425d2aa%26relation%3Dparent.parent%26transport%3Dpostmessage&href=http%3A%2F%2Fwww.rjwcollective.com%2Fequinox%2Frishi_gallery%2Feqgall.php&layout=button_count&locale=en_US&node_type=link&sdk=joey&show_faces=false&width=90

You will have to modify that src (!), or the easier way may be to just remove the like button and create a new one in its place.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top