Phill Greggan
Phill Greggan

Reputation: 2394

how do i find the path to menu items?

i have menu setup in the following hierarchy

<body class='default'>
            <div id='jqx' style='visibility: hidden; margin-left: 5px;'>
                <ul>
                    <li><a href="HtmlPage1.html">Home</a></li>
                    <li>Solutions
                        <ul style='width: 250px;'>
                            <li><a href="#Education">Education</a></li>
                            <li><a href="#Financial">Financial services</a></li>
                            <li><a href="#Government">Government</a></li>
                            <li><a href="#Manufacturing">Manufacturing</a></li>
                            <li type='separator'></li>
                            <li>Software Solutions
                                <ul style='width: 220px;'>
                                    <li><a href="#ConsumerPhoto">Consumer photo and video</a></li>
                                    <li><a href="HtmlPage2.html">Mobile</a></li>
                                    <li><a href="#RIA">Rich Internet applications</a></li>
                                    <li><a href="#TechnicalCommunication">Technical communication</a></li>
                                    <li><a href="#Training">Training and eLearning</a></li>
                                    <li><a href="#WebConferencing">Web conferencing</a></li>
                                </ul>
                            </li>
                            <li><a href="#">All industries and solutions</a></li>
                        </ul>
                    </li>
        </ul>
         </div>
</body>

assume i need to write the click event for menu items, but how do i write the click event for all menu items?

i know i can use

   $('a').on('click', function (e) {
        e.preventDefault();
        var page = $(this).attr('href');
        $('#content').load(page);
    });

this works for 'a' but instead of the passed 'a' how do i write the click event to all menu items?

thanks

Upvotes: 0

Views: 28

Answers (1)

charlietfl
charlietfl

Reputation: 171669

Use the parent menu ID to islolate only menu a

$('#jqx a').on('click....

Translates to all descendant a of id="jqx"

Upvotes: 1

Related Questions