Classic Like button code :
<div class="fb-like" style="position:relative;float:left;" data-href="http://www.mywebsite.com/?IDL=1" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
<div id="fb-root"></div>
<script type="text/javascript">
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
</script>
it render the I Like Facebook button to the http://www.mywebsite.com/?IDL=1 page. Now, suppose I’d like, due to some action on the page, change the destination to http://www.mywebsite.com/?IDL=2 : how can I do it? I need to destroy and create again the button? I mean dynamically, without “refresh” the page (which will be easy)
You’ll need to destroy the already initialized button and replace it with another one then call
FB.XFBML.parse()which will reparse the XFBML and re-initialize the new button.