Овај сајт ће имати ограничену функционалност док га будемо ажурирали у циљу побољшања вашег искуства. Ако неки чланак не реши ваш проблем и желите да поставите питање, на располагању ће вам бити наше заједнице подршке @FirefoxSupport на Twitter-у и /r/firefox на Reddit-у.

Претражи подршку

Избегните преваре подршке. Никада од вас нећемо тражити да зовете или шаљете поруке на број или да делите личне податке. Пријавите сумњиве радње преко „Пријавите злоупотребу” опције.

Сазнај више

Click event incorrectly associated after DOM manipulation

  • 1 одговор
  • 1 има овај проблем
  • 1 преглед
  • Последњи одговор послао 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.

Изабрано решење

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.