jquery ctrl+enter as enter in text area

后端 未结 6 1953
南旧
南旧 2020-12-30 07:33

I am trying to reproduce standard instant messenger behavior on TEXT area control: enter works as send button. ctrl+enter as real enter.

 $(\"#txtChatMessag         


        
6条回答
  •  没有蜡笔的小新
    2020-12-30 08:12

    A few potential causes:

    Define the function before you reference it.

    Make sure you're binding the event in the document.ready event, so that the dom item exists when you reference it.

    Change else (e.keyCode == 13) to else if (e.keyCode == 13).

    Make sure this is a textarea, not an input[type=text].

    Consider using keypress instead of keydown.

    Some browsers will send keyCode == 10 instead of keyCode == 13 when using the ctrl modifier key (some browsers will send it even when you aren't using the ctrl modifier key).

提交回复
热议问题