Javascript sending key codes to a <textarea> element

前端 未结 5 1019
说谎
说谎 2020-12-18 14:58

I can\'t figure out how to trigger a keydown event on a textarea element, e.g. imagine i have two textarea elements and when i type something in the first one, I want the se

5条回答
  •  生来不讨喜
    2020-12-18 15:26

    The keydown event is not responsible for actually updating the value of the textbox. Your code works just fine, but since you don't have an event handler on the second textbox, it doesn't look like anything happens. If you want to update the text in the textbox, change its value, as demonstrated by jyoseph.

    If you need to trigger the event as well (for some reason), your code as written will do that.

提交回复
热议问题