Mozilla 도움말 검색

고객 지원 사기를 피하세요. 저희는 여러분께 절대로 전화를 걸거나 문자를 보내거나 개인 정보를 공유하도록 요청하지 않습니다. "악용 사례 신고"옵션을 사용하여 의심스러운 활동을 신고해 주세요.

자세히 살펴보기

Click event incorrectly associated after DOM manipulation

more options

I have a page with input elements and a span element styled as a button. I register change event handlers on the input elements, to do validation when the input values are changed. If the inputs are invalid, I add content to a div on the page to indicate the problem. I also register a click event handler on the span styled as a button.

When I edit an input then immediately click on the span (i.e. without focus leaving the input element before clicking on the span) I see:

1) mousedown on span 2) change on input 3) mouseup on input

This occurs only when I modify the DOM in the change event handler on the input. If I don't modify the DOM then I see:

1) mousedown on span 2) change on input 3) mouseup on span 4) click on span

In the first case, I see the mouseup associated with the input element rather than the span element, even though it has the same coordinates as the mousedown which is associated with the span element. Given the coordinates are within the bounds of the span element and outside the bounds of the input element, I don't understand why the mouseup is associated with the input element rather than the span element.

There is an example of this at http://jsfiddle.net/4zx8rm7c/.

I see this behaviour in Firefox 34.0.5 and Chrome 39.0.2171.95 m.

If the association of the mouseup event with the input element, despite the seemingly unrelated coordinates of the mouse event, is intended behaviour, I need to understand why this is. I have looked at COM Level-2 event specifications (briefly) and I don't see an obvious explanation.

I have a page with input elements and a span element styled as a button. I register change event handlers on the input elements, to do validation when the input values are changed. If the inputs are invalid, I add content to a div on the page to indicate the problem. I also register a click event handler on the span styled as a button. When I edit an input then immediately click on the span (i.e. without focus leaving the input element before clicking on the span) I see: 1) mousedown on span 2) change on input 3) mouseup on input This occurs only when I modify the DOM in the change event handler on the input. If I don't modify the DOM then I see: 1) mousedown on span 2) change on input 3) mouseup on span 4) click on span In the first case, I see the mouseup associated with the input element rather than the span element, even though it has the same coordinates as the mousedown which is associated with the span element. Given the coordinates are within the bounds of the span element and outside the bounds of the input element, I don't understand why the mouseup is associated with the input element rather than the span element. There is an example of this at http://jsfiddle.net/4zx8rm7c/. I see this behaviour in Firefox 34.0.5 and Chrome 39.0.2171.95 m. If the association of the mouseup event with the input element, despite the seemingly unrelated coordinates of the mouse event, is intended behaviour, I need to understand why this is. I have looked at COM Level-2 event specifications (briefly) and I don't see an obvious explanation.

선택된 해결법

This forum is intended for user support, not for web development issues. Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The contributors over there are more knowledgeable about web page development issues with Firefox. http://forums.mozillazine.org/viewforum.php?f=25 You'll need to register and login to be able to post in that forum.

문맥에 따라 이 답변을 읽어주세요 👍 0

모든 댓글 (1)

more options

선택된 해결법

This forum is intended for user support, not for web development issues. Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The contributors over there are more knowledgeable about web page development issues with Firefox. http://forums.mozillazine.org/viewforum.php?f=25 You'll need to register and login to be able to post in that forum.