Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
似乎是一个奇怪的问题,但可能是一个简单的答案。
看看这个CodePen。
您会看到我已将其设置在 on 的位置mousedown,它会检查选定的文本。如果为真且不为空,则设置text_selected为 1(或真)并返回所选文本。
mousedown
text_selected
On mouseup,如果 text_selected是真的,它应该打印 1 和选定的文本......但它没有!
mouseup
如果你第二次点击它,它会,但这并不好。为什么之前不更新mouseup?