web2tips
web2tips

Reputation: 191

Override click event is not working

I am trying to override some click event on the following domain but it won't work. After clciking on call button it will open a dialog, where it has a apply button I want to go some other website when click on that button, now it opens another dialog after clicking on that button. I have used the following code to override the click event but it dose not work.

    <!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>My Website</title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type='text/javascript'>
/* <![CDATA[ */
var soload = {"lang":"en","dir":"LTR","cookieOptions":{"domain":".hellobrokers.com"},
        "packages":{"Clock":{},
        "RegularPlatform":{"settings":{"selector":"#so_container"}}
}};
/* ]]> */
</script>
<script type='text/javascript' src='//spotplatform.hellobrokers.com/SpotOptionPlugin.js?ver=4.1.1'></script>
<script type="text/javascript">SO.load(soload);
</script>
<script>(function() {
var _fbq = window._fbq || (window._fbq = []);
if (!_fbq.loaded) {
var fbds = document.createElement('script');
fbds.async = true;
fbds.src = '//connect.facebook.net/en_US/fbds.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(fbds, s);
_fbq.loaded = true;
}
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', '6022904954366', {'value':'0.01','currency':'EUR'}]);
</script>
</head>
<body>
<div id="bgbanner">
    <div id="index">
        <div class="mainContent">
            <div id="so_container">
                <div align="center" class="please_wait"> 
                <img border="0" src="img/ajax-loader.gif" alt="" /><br />
                    <br />
                    Please Wait<br />
                    <br />
                    Loading</div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function() {
        $('.applyApprove').unbind();

        $(".applyApprove").click(function() {
            window.location = 'http://www.google.com';
        });
    });
</script>
</body>
</html>

Upvotes: 0

Views: 297

Answers (2)

Sohel
Sohel

Reputation: 431

Instead of .unbind(), use .off('click') and it should work:

<script>
    $(document).ready(function(){
         $("button.applyApprove").off('click');

         $("button.applyApprove").click(function(){
            window.location = "http://www.google.com";
         });
    });
</script>

Upvotes: 1

Sumner Evans
Sumner Evans

Reputation: 9157

Just use $('.applyApprove') instead of $('button.applyApprove') (notice no button):

<script>
    $(document).ready(function() {
        $('.applyApprove').unbind();

        $(".applyApprove").click(function() {
            window.location = 'http://www.google.com';
        });
    });
</script>

Upvotes: 0

Related Questions