Solved

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

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
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

617 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