calling a click event inside nested divs won't fire

Hi There,

I'm having some issues trying to fire click event using jquery. The event works fine if I move the image outside the nested divs but as soon as I put the image back the function just wont work.

Can someone help me out with the syntax please and help me get the id value from the object so I can send it with the ajax call.

Thanks in advance.

Sean
$(document).ready(function() {
  // Add the page method call as an onclick handler for the div.
  $("#slideShowHeader.numbdots.offer-buttons" ).click(function() {
    $.ajax({
      type: "POST",
      url: "mypage.aspx",
      data: "{}",
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(msg) {
        // Replace the div's content with the page method's return.
        $("#Result").text(msg.d);
      }
    });
  });
});
 
 
 
<div id="slideShowHeader">
   
 <div id="numbdots">
     <img src="../images/4_Button.gif" id="one" alt="" class="offer-buttons"/>
 
  </div>
     
</div>

Open in new window

LVL 8
MrAgileAsked:
Who is Participating?
 
Albert Van HalenAnalyst developerCommented:
Your getting an element with className numbdots and it should be the id in your jquery selector.

Use $("#slideShowHeader #numbdots .offer-buttons")
PS Mind the space in between.
0
 
MrAgileAuthor Commented:
Hi There,

Thanks for that!

Sean
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.