Jpaji Rajnish Jpaji Rajnish - 5 months ago 9x
Javascript Question

Can't set the data-href attribute of fb widget

I have a variable that changes depending on which host my webpage is running and I'm trying to dynamically set the

attribute of the fb share widget but I can't get it to be set to anything, it just remains unchanged. This is the last thing I tried:

$( ".fb_iframe_widget" ).data( "href", CONFIG['domain'] );


You have to use .attr() in order to set data-* value as shown :-

$( ".fb_iframe_widget" ).attr("data-href", CONFIG['domain']);