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?

asked Jul 16, 2012 at 7:13

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.

Jezen Thomas
13.8k7 gold badges55 silver badges95 bronze badges
answered Jul 16, 2012 at 7:59
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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