Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Ignore span.click() inside td.click()

Posted on 2013-01-21
1
Medium Priority
?
299 Views
Last Modified: 2013-01-22
I currently have a function acting on a td.click() as follows:

$('#tsTable').on('click', 'table tbody tr td:nth-child(2)', function(e) {

// other code here

});

I also have a span inside this td which has its own click function:

$('#tsTable').on('click', 'span.tag', function(e) {

// other code here

});

How do I stop the td.click function from triggering when I click the span.tag which is inside the td?  I only want the td.click function to trigger if the td is clicked outside the span.tag.

Hope this makes sense.
0
Comment
Question by:ShanghaiD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
Khilu earned 2000 total points
ID: 38804583
Use return false;

http://jsfiddle.net/bN4CD/4/

$('#tsTable').on('click', 'td', function(e) {

alert('TD');

});

$('#tsTable').on('click', 'span', function(e) {

alert('Span');
return false;
});

Open in new window

0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

715 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