【问题标题】:Mootools: Get Textbox Text on Keydown EventMootools:在 Keydown 事件上获取文本框文本
【发布时间】:2012-01-29 11:35:12
【问题描述】:

如何在 keydown 事件处理程序中获取文本框的当前文本。调用 element.get('value') 会返回 事件发生前文本框中的文本。如何在事件处理程序中获取当前值?

【问题讨论】:

    标签: javascript mootools keydown mootools-events


    【解决方案1】:

    只需使用keyup 事件代替:)

    $('yourTextarea').addEvent('keyup', function() {
    
        var value = this.get('value');
        console.log('value');
    
    });
    

    【讨论】:

    • Good ;) 如果出于同样的原因您需要在 keydown 中执行此操作,您可以检索用户按下的键(它必须类似于 function(e) { e.key; /* or */ e.code; },并使用它来追加当前文本的一个字符。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多