Back to my framework again. I have a method which gets the element's value, clears the element's value in dom, and then puts it back in letter by letter. Tested it in Chome, FF and IE (10). Everything is working fine. But there's a small problem with IE. It won't clear the element's value if I refresh the page while the script is executing. Or after it, doesn't really make a difference.
<textarea cols="60" id="textarea">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas suscipit lacus non hendrerit cursus.
</textarea>
<script>
(function(){
(this[arguments[0]] = function selector(id){
if(!(this instanceof selector)) {
return new selector(id);
}
this.elm = document.getElementById(id);
}).prototype = {
type: function(delay) {
var elm = this.elm;
var status;
if ('value' in elm) {
var text = elm.value;
elm.value = "";
status = 0;
} else if ('innerHTML' in elm) {
var text = elm.innerHTML;
elm.innerHTML = "";
status = 1;
}
var letters = text.split("");
var counter = 0;
function write() {
if (counter < letters.length) {
switch (status) {
case 0: elm.value += letters[counter]; break;
case 1: elm.innerHTML += letters[counter]; break;
}
}
counter += 1;
}
setInterval(write, delay);
},
};
})('$');
$('textarea').type("100");
Is this IE related problem or am I missing something in the code? I feel like it's probably IE >.>