0

Below code is jquery function

$(document).ready(function () {
   $('#access').accordion({
      create: function (event, ui) {
          $('div#access> div').each(function () {
              var id = $(this).attr('id');
            $(this).load(id+'.html', function () {
                $('#access').accordion('resize');
            });
        });
    }
});
});

where access is the div id i have used for menu items in header.

below code is header.php page code

<div id="access" >
    <ul>        
        <?php wp_list_pages('depth=1&title_li=');?>
    </ul>
</div>

what i want is onclick of the menu item the javascript function should be called..

how to call function from php file?

1 Answer 1

1

You don't call the JavaScript function from PHP. The PHP merely enables you to build the HTML page dynamically. Once the page is ready, the JavaScript is called and it starts binding the events to the appropriate elements.

What you need to do is look at the generated code using the 'view source' or firebug and explore the structure of the generated HTML and then you can bind the event to the requested element.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.