Reputation: 339
In HTML I have text in text tag:
<text id="aaa" > text</text>
Is it possible to add onclick event to this ?
Tried
var a = document.getElementById('aaa');
a.elemm.addEventListener('click', function(){ alert('blah');}, false);
Upvotes: 0
Views: 9197
Reputation: 3207
try to something like this.
<text id="aaa" > text</text>
var a = document.getElementById('aaa');
a.addEventListener('click', function(){ alert('Text has been changes');}, false);
Upvotes: 0
Reputation: 12399
You're almost there! Just change a.elemm.addEventListener
to a.addEventListener
:
var a = document.getElementById('aaa');
a.addEventListener('click', function(){ alert('blah');}, false);
<text id="aaa"> text</text>
Upvotes: 3
Reputation: 756
This works:
var a = document.getElementById('aaa');
a.addEventListener('click', function(){ alert('blah');}, false);
You just have a little mistake
Upvotes: 0