jeudi 16 juin 2016

Wordpress Nav / Menu onClick event solution

Okay, I have a problem: I have this code that creates a button, but I need that same onClick event in my wordpress menu www.slingerbistro.dk (the top right corner - booking button).

I've read, that it requires to put in some coding in the header.

The booking code I've received is like this:

<!-- DinnerBooking Booking Box Start -->
<script type="text/javascript" src="http://js.i.dinnerbooking.eu/onlinebooking.js"></script>
<a onclick="return openDBWindow(this.href);" href="http://slingerbistro.b.dinnerbooking.com/onlinebooking/997/2" id="wd_booking_btn" title="Se ledig tid og book bord" class="btn_blue"><span>Se ledig tid og book bord</span></a>
<!-- DinnerBooking Booking Box End -->

And what I've done is trying to get that into my header.php in the theme. So far I've come up with this:

<script type="text/javascript" src="http://js.i.dinnerbooking.eu/onlinebooking.js">
jQuery(document).ready(function($) {
    $("#menu-item-top-level-10").on("click", function(e){
          e.preventDefault();
          // dinnerbooking code here
          return openDBWindow (this.href == "http://slingerbistro.b.dinnerbooking.com/onlinebooking/997/2")
    });
}); </script>

Does anybody have the skills to look at my sorry excuse for a code and correct it? I'm not a programmer (obviously) and could really need your help.

The booking button has "#menu-item-top-level-9" so basically the code I'm trying to write should give the same effect with the drop-down-widget as the sample widget I posted on top.

Thank you <3

Aucun commentaire:

Enregistrer un commentaire