Jpaji Rajnish Jpaji Rajnish - 2 years ago 86
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'] );

Answer Source

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

$( ".fb_iframe_widget" ).attr("data-href", CONFIG['domain']);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download