现在的位置: 首页 > 综合 > 正文

style.backgroundImage will fire onpropertychange twice

2013年09月04日 ⁄ 综合 ⁄ 共 537字 ⁄ 字号 评论关闭

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...

抱歉!评论已关闭.