Skip to content Skip to sidebar Skip to footer

How Do I Find The Id Of An Element That Was Clicked?

Say I have an many html elements, a row in a table composed of table data () tags. foobar.

Solution 2:

Simply, this.id:

$("td").click(function() {
  console.log(this.id)
})
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><table><tr><tdid="data1">foo</td><tdid="data2">bar</td><tdid="data3">baz</td></tr></table>

Post a Comment for "How Do I Find The Id Of An Element That Was Clicked?"