0

I am using balupton ajaxy plugin.

I am trying to add a class on an element with on("click") function but due to the ajaxy plugin that handles the click function on the specific element , it doesn't work.

I have this list:

<ul class="menu">
   <li><a href="company.html" class="ajaxy ajaxy-page"> company</a>
   <ul>
      <li><a href="aboutus.html" class="ajaxy ajaxy-page">aboutus</a></li>
      <li><a href="contactus.html" class="ajaxy ajaxy-page">contactus</a></li>
      </ul>  
      </li>
   <li><a href="services.html" class="ajaxy ajaxy-page">services</a></li>
</ul>

I have tried this, and it works for the "li" but not for the "a" element.

$(".menu li").on("click", function(){
  alert("aa");
});

Any help would be appreciated.

JMast
  • 15
  • 4

2 Answers2

0

I would put your new click handler outside of the plugin code, probably after it.

//Plugin code here
// $(".menu li").click(function(){
  alert("aa");
 });

Alternatively, you could explore if the AJAXY plugin offers a callback feature?

Barney
  • 1,820
  • 5
  • 29
  • 50
0

I would try this if you want the LI and also the A to respond:

$(document).ready(function(){
  $(".menu li,.menu a").on("click", function(){
    alert("aa");
  });
});
  

And do not forget to call it in document ready, so that it is inicilazed after the plugin is.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Asped
  • 3,083
  • 4
  • 31
  • 52