Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

javascript - type @, show a name list like facebook status box

in facebook status box, if you type '@', then a list of friends' names appear. I am trying to implement such a status box.

But the problems are:

On typing '@', where should the 'div's location be and how to show the list? I just can't make anything out of it.

I went through this question of SOF, but that actually does not discuss that.

Anybody there to shed light on it as much as possible?

My choice is jquery.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From a quick glance at facebook, it appears that there is a <div> tag that renders the highlighted content along side the text content.

The text is captured one keystroke at a time by onKeyUp events on the <textarea> element (transparent and overlayed on top of the div with the visible content) and transposed into the <div> element. When examining the key up events, simply check if the key is '@' and fire the menu event.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...