Solved

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

Posted on 2013-01-21
1
292 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
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…

749 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