Link to home
Start Free TrialLog in
Avatar of Lance McGrew
Lance McGrewFlag for United States of America

asked on

CONVERT JAVASCRIPT BUTTON TO HYPERLINK TEXT

The current code displays a "button".   I want code to just display text "Post Your Event" with same action as button does.

<script class="ai1ec-widget-placeholder" data-widget="ai1ecfs_widget" data-button_size="md">
  (function(){var d=document,s=d.createElement('script'),
  i='ai1ec-script';if(d.getElementById(i))return;s.async=1;
  s.id=i;s.src='//live-timely-0zd7rybdr3.time.ly/?ai1ec_js_widget';
  d.getElementsByTagName('head')[0].appendChild(s);})();
</script>
Avatar of Frank Danny
Frank Danny
Flag of United States of America image

Can you   please put  that  code  in  <code>  <code>?It is very  confusing  the way it is now
Avatar of Lance McGrew

ASKER

<script class="ai1ec-widget-placeholder" data-widget="ai1ecfs_widget" data-button_size="md">
  (function(){var d=document,s=d.createElement('script'),
  i='ai1ec-script';if(d.getElementById(i))return;s.async=1;
  s.id=i;s.src='//live-timely-0zd7rybdr3.time.ly/?ai1ec_js_widget';
  d.getElementsByTagName('head')[0].appendChild(s);})();
</script>

Open in new window

Avatar of Julian Hansen
All that script does is load a widget (external javascript) that renders the button. To change it you would need to change the src it is referring to i.e
//live-timely-0zd7rybdr3.time.ly/?ai1ec_js_widget

In other words you would have to change the widget at src

What you can do is modify it after it is loaded.

This is tricky because the page loads and the button is created dynamically after this so you need to check when the button is created. To do this we need to listen for the DOMNodeInserted event and then run some JavaScript / jQuery to remove the button class from the widget.

We can do this with jQuery like so

<script src="http://code.jquery.com/jquery.js"></script>
<script>
$(function() {
	$(document).on('DOMNodeInserted', function() {
		$('a.ai1ec-btn').removeClass('ai1ec-btn ai1ec-btn-primary ai1ec-btn-md');	
	});
});
</script>

Open in new window


Working sample here
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Julian, I experimented with both your solutions and found the CSS method cleanest option.  Works just fine. Your coding skills are certainly impressive.  Thank you for taking quality time to share.
Thank you Lance and you are most welcome.