This is only for internet explorer, firefox doesnt have any problem.
Expand|Select|Wrap|Line Numbers
- i = 666;
- myImg = document.createElement("img");
- myImg.setAttribute('onClick', 'doSomething(\'' +i+ '\');'); //this works
- myDiv = document.createElement("div");
- myDiv.setAttribute('onClick', 'doSomething(\'' +i+ '\');'); //this doesn't
so setAttribute for the onclick event works but not for Divs.
Anybody know why? Wouldnt this take extra coding to stop the function working?
this is the work around ive used anyway; after checking if the user is on IE:
Expand|Select|Wrap|Line Numbers
- myDiv.onclick = new Function( "return dosomething('" + i + "');" );
god i hate IE.