0

I got a HTML table, that consists of:

<td contenteditable="true">

And I have some function:

f()
{
  alert("pew");
}

What should I do to call the function, when I click on my "td"?

OnClick="f();"

doesn't seems to be working.

Dinoabunai
  • 31
  • 3

3 Answers3

0

You can try below link its has the same question. contenteditable change events

Hope it helps.

0

You can try something like this:

function f()
{
  console.log("pew");
}
document.getElementById("mytd").addEventListener("click", function() {
    f()
}, false);
<table>
  <tr>
    <td contenteditable="true" id="mytd">Content</td>
  </tr>
</table>
-1

Try to remove the semicolon from onclick="f()", should be work