javascript - JS输入编辑框实现输入@提示@人
本文介绍了javascript - JS输入编辑框实现输入@提示@人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
1、输入编辑框当输入@的时候弹出提示,类似QQ聊天输入@人的效果
<div contenteditable=true></div>
2、输入效果:
解决方案
推荐一个我曾经贡献过代码的jquery插件(23333,也只是帮他们改了个Bug)
https://github.com/ichord/At.js
demo
Features Preview
Support IE 7+ for textarea. Supports HTML5 contentEditable elements
(NOT including IE 8) Can listen to any character and not just '@'. Can
set up multiple listeners for different characters with different
behavior and data Listener events can be bound to multiple inputors.
Format returned data using templates Keyboard controls in addition to
mouse Tab or Enter keys select the value Up and Down navigate between
values (and Ctrl-P and Ctrl-N also) Right and left will re-search the
Custom data handlers and template renderers using a group of
callbacks Supports AMD
这篇关于javascript - JS输入编辑框实现输入@提示@人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文