Events on children of contenteditable element

后端 未结 3 1858
故里飘歌
故里飘歌 2021-01-19 17:05

I have

myDiv.bind(\'keypress\', \'> *\', function(event) { console.log(\'keypress\') });

but it does not seem to work.

myDiv is

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-19 17:58

    The issue may not be the selector, but rather that the

    is always the event.target.

    $('#test').on('keypress', function (e) {
        console.log(e.target);
    });
    

    With this, at least in Chrome, the console just logs:

    ...
    ...
    ...
    ...
    ...
    ...
    ...

提交回复
热议问题