Jquery – Change data-href on like button

attrfacebook-likejquery

Is this possible?

I've got this HTML:

<div id='fbLike' class="fb-like" data-href="http://www.google.se" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false" data-font="tahoma">

and this Jquery:

 $('#fbLike').attr('data-href',item_Url)

It seems it won't change when I fire that function, any ideas anyone?

Thanks!

Best Solution

Try

$('#fbLike').data('href', item_Url)

Also see

http://api.jquery.com/jQuery.data/