I am not a gold star medal with Javascript, so please bear with me.
We have an addition on the site that is being loaded externally via a a javascript (its called ratecard), however the link that is supplied that the item is being used for isnt correct, so with a little javascript/jquery we are trying to overwrite it.
As the plugin is loaded it adds to a predefined div a location.href. I am trying to overwrite this via following javascript.
This is the div that is being generated
<div class="wdgt_widget" style="border:1px solid #1d8be0 !important; border-radius:8px !important; padding:11px !important; width:300px !important; height:64px !important; cursor:pointer !important; box-sizing: border-box !important;" onclick="location.href='https://ratecard.io/staffing-ms'"></div>
So I am trying to unbind the click action first and add a new one, yet nothing happens. See script below.
<script>
jQuery(document).ready(function ($) {
setTimeout(function() {
$('#wdgt_widget').unbind();
$('#wdgt_widget').attr('click' 'location.href="https://ratecard.io/staffing-ms/review/");
}, 5000);
});
</script>
I added a 5 second timer on it, since i wanted to make sure the code would be loaded and div already be generated.
Sadly nothing happens. Is there a possibility to simply use replace on the onclick? or did i do something wrong here?
.wdgt_widgetinstead of#wdgt_widget. I Suppose. Since yourdivdoesn't have a id.onclicknotclickunbind()doesn't unbind inline script. And you have synthax error in your posted code...