Hi I have been trying to add onclick event to new elements I added with javascript. the problem is when I check document.body.innerHTML I can actually see the onclick=alert('blah') is added to the new element.
but when I click that element I don't see the alert box is working. in fact anything related to javascript is not working.. here is what I use to add new element:
function add_img()
{
var elemm = document.createElement('rvml:image');
elemm.src = 'blah.png';
elemm.className = 'rvml';
elemm.onclick = "alert('blah')";
document.body.appendChild(elemm);
elemm.id = "gogo";
elemm.style.position='absolute';
elemm.style.width=55;
elemm.style.height=55;
elemm.style.top=200;
elemm.style.left=300;
elemm.style.rotation=200;
}
here is how I call this function:
<button onclick=add_img()>add image</button>
now the image draws perfectly inside the browser. but when I click the image I don't get that alert.
any help would be appreciated..