Where did you install Firefox from? Help Mozilla uncover 3rd party websites that offer problematic Firefox installation by taking part in our campaign. There will be swag, and you'll be featured in our blog if you manage to report at least 10 valid reports!

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

Click event incorrectly associated after DOM manipulation

  • 1 trả lời
  • 1 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi the-edmeister

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.

Giải pháp được chọn

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.

Đọc câu trả lời này trong ngữ cảnh 👍 0

Tất cả các câu trả lời (1)

more options

Giải pháp được chọn

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.