style.backgroundImage will fire onpropertychange twice

来源:互联网 发布:大连 大数据 招聘 编辑:程序博客网 时间:2024/05/28 23:21

We all know IE is weird:

<input id="mytestinput" onclick="this.style.backgroundImage='url(http://blog.csdn.net/images/authorship.gif)';" type="button" value="change background image" />
<script>
document.getElementById('mytestinput').attachEvent(
    'onpropertychange', function () { alert(event.propertyName); });
</script>

click the button will alert twice.

If u set backgroundImage to 'none', it will also alert twice, however, set to ''(empty string), will only once...

原创粉丝点击