Zhe*_*hen 0 javascript jquery textbox coffeescript
我试图在coffeescript/jquery中实现以下内容
- >当用户输入时,检查textBox是否为空(或者有"写评论..."文本),隐藏"添加评论"按钮.否则显示"添加评论"按钮
但是,我面临的问题是从文本框返回给我的val()始终是一个键击.
例如,如果我在框中键入'sad',则target.val()仅返回'sa'.
在输入时如何在文本框中获取最新值?
我的实现如下
events:
"keydown .comment_area": "commenting"
commenting: (e) ->
target = @$(e.currentTarget)
//target.val() is not returning me the latest character entered in the box
if $.trim(target.val()) == "" or $.trim(target.val()) =="Write a comment..."
//hide the 'add' button
@$('.add_comment').hide()
else
//show the 'add' button
@$('.add_comment').show()
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
829 次 |
最近记录: |