?
Solved

calling a click event inside nested divs won't fire

Posted on 2008-11-20
2
Medium Priority
?
325 Views
Last Modified: 2012-06-21
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

0
Comment
Question by:MrAgile
2 Comments
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 2000 total points
ID: 23002036
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
 
LVL 8

Author Comment

by:MrAgile
ID: 23009317
Hi There,

Thanks for that!

Sean
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question