IE vs Firefox


Lately I was working on Javascript and I came across a problem that was just because of some difference in browsers.
What I was trying to do was, using Javascript I was creating HTML elements dynamically as per requirement and setting different attributes of these elements. While doing so I used setattribute function to set the attribute of the elements. It worked very fine on FF but It started giving problem on IE(sucking IE).

So I kept searching for many solutions to make it working on IE as well as FF.  As searching and getting a solution was a tough job, may be I was not very good at googling for it.. 😦

Let me first write the code that was working on FF but not IE:

ele = document.createElement('input'); //works on IE as well as FF
ele.setAttribute("type", "checkbox"); // works on IE as well as FF
ele.setAttribute("onclick", "myFunc(parameters);"); //Works only on FF
li.appendChild(ele); //li is my list element, appended the checkbox to it

The Code that worked for both is as under:(Solution)

ele = document.createElement('input'); //works on IE as well as FF
ele.setAttribute("type", "checkbox"); // works on IE as well as FF
ele.onclick = function{ myFunc(parameters);}; //Works for both FF & IE
li.appendChild(ele); //li is my list element, appended the checkbox to it

Cheers.. Hope I helped you.. 🙂