Solved

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

Posted on 2013-01-21
1
284 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
1 Comment
 
LVL 3

Accepted Solution

by:
Khilu earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now