Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
172
rated 0 times [  176] [ 4]  / answers: 1 / hits: 28400  / 12 Years ago, sun, april 15, 2012, 12:00:00

I have the following HTML:



<div class=server id=32>
<a>Server Name</a>
<div class=delete-server>X</div>
</div>


I am trying to make it so when users click the server div it brings up an edit dialog. The problem is simply doing:



 $(.server).click(function () {
//Show edit dialog
});


Does not work, because if they click the X which is delete, it brings up the edit dialog. How can make the entire div server have the click event except the delete-server div.


More From » jquery

 Answers
47
$(.server).on('click', ':not(.delete-server)', function (e) {
e.stopPropagation()
// Show edit dialog
});


Here's the fiddle: http://jsfiddle.net/9bzmz/3/


[#86233] Friday, April 13, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nolancampbellc

Total Points: 9
Total Questions: 102
Total Answers: 101

Location: Saint Vincent and the Grenadines
Member since Mon, Jan 16, 2023
1 Year ago
nolancampbellc questions
Thu, Sep 23, 21, 00:00, 3 Years ago
Mon, Nov 23, 20, 00:00, 4 Years ago
;