Ivan
Ivan

Reputation: 251

CSS + JQUERY + event.preventdefault

In this table, the row has a event in jquery and execute it when i click in the row, inside of the row there are a div... these div has too a event and this execute when i click in the div. but when i click in the div too execute the event of the row....

<table>
 <tr id="one">
  <td>
   <div id="two">
    Hellow world
   </div>
  </td>
 </tr>
</table>

So, when i click in the div, i want execute only the event of the div. how?

Upvotes: 0

Views: 165

Answers (2)

ssilas777
ssilas777

Reputation: 9764

Use jquery, and make sure you pass "event" as parameter to the function

 $(document).on('click', '.desplegar' , function(event) {
  .................
  event.stopPropagation();
 });

this will prevent bubbling up of events.

Upvotes: 1

King Friday
King Friday

Reputation: 26106

ev.stopPropagation()

is what you are wondering about.

Upvotes: 5

Related Questions