Of course you can, because
document.createElement
returns DOM element.
The only problem is that your freshly created element does not exist in the DOM of your document: you did not append or insert it in the code you show in your question.
Please see the documentation page demonstrating how to create an element and add it using
element.appendChild
(for example):
http://reference.sitepoint.com/javascript/Document/createElement[
^].
[EDIT]
Of course, to handle an event by the freshly created element, use the variable immediately:
element.onmouseover = function() { }
What you are doing in the cycle is not clear: you handle mouse events of different list item elements in the same way; modify properties of the same element
element
in the same way. Why? Just think about it.
—SA