0

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");
});       
});
Gajotres
  • 57,309
  • 16
  • 102
  • 130
Brandon
  • 2,163
  • 6
  • 40
  • 64

2 Answers2

5

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/

Gajotres
  • 57,309
  • 16
  • 102
  • 130
1

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

 $('div[data-role="navbar"] a').on('click', function () {
      alert("div E clicked");
 });   
Devang Rathod
  • 6,650
  • 2
  • 23
  • 32