Question

I am trying to revise the following jQuery Mobile code to display if the navbar with the id "e" is clicked. The code below works for all of the navbar items, but I only want the alert to appear if the navbar with the id "e" is clicked. Any help revising this would be great. Thanks much!

$(document).on('pagebeforeshow', '#p_page', function(event){       
    $('div[data-role="navbar"] a').live('click', function () {

        alert("div E clicked");
});       
});
Was it helpful?

Solution

This should work:

$(document).on('pagebeforeshow', '#p_page', function(event){       
    $('div[data-role="navbar"] ul li a#e').on('click', function () {
        alert("div E clicked");
    });       
});

Working example: http://jsfiddle.net/Gajotres/rnRqm/

OTHER TIPS

Instead of live use click event because live is deprecated from jquery.

 $('div[data-role="navbar"] a').on('click', function () {
      alert("div E clicked");
 });   
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top