I'm trying to make a site where the user can click on any element to edit it's CSS. I use the following to add the click function to all <li>
, <div>
and <ul>
.
$('li,div,ul').click(function () {
alert(this.id);
});
The problem is if I click on a <li>
element, then I get the alert for that and any element underneath it. (all the containers).
Is it possible to have only the top element trigger when clicked?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…