javascript - function for dynamically created <a> tag is not working -


i working on mobile website html,js , css.i have created tag through html5 dom & assigned functions it. it's not working.

my html code(which have tried thro' dom method);

    <script>             var addexhibits = document.getelementbyid('mycontent');             function mytest()             {     var div = document.createelement('div');     div.id = 'rateme';     var anchor = document.createelement('a');     anchor.id="_1";     anchor.onclick = rateit(this);     anchor.onmouseover=rating(this);     anchor.onmouseout=off(this);             div.appendchild(anchor);             addexhibits.appendchild(div);             }    </script>    <body><div id='mycontent' title="rate me..."></body> 

code(statically created tag - works fine)

<div id="rateme" title="rate me..."> <a onclick="rateit(this)" id="_1" onmouseover="rating(this)" onmouseout="off(this)"></a> </div> 

rate(this) function in external js(http://reignwaterdesigns.com/ad/tidbits/rateme/)

your event handler assign result of respective function calls here:

anchor.onclick = rateit(this); anchor.onmouseover=rating(this); anchor.onmouseout=off(this); 

i assume want them execute in case of event instead:

var = this; anchor.onclick = function(){ rateit(that); }; anchor.onmouseover = function(){ rating(that); }; anchor.onmouseout= function(){ off(that); }; 

Comments