开发者

How do I set focus on a div with contenteditable?

I have looked through the site and couldn't find a question that solved my problem, so I am asking it here.

I am doing some programming in html and jquery and have bumped into a problem.

What I want to happen: I have a div that is user-editable with the contenteditable tag. When you click the date, the text goes away so you can type in text.

What happens: I have a div that is user-editable with the contenteditable tag. When you click the date, the text goes away, but you can't type in text without clicking the div again..

Here is my code: 开发者_StackOverflow社区 http://jsfiddle.net/3Ve4U/.

How do I fix this? I am using Chrome if that helps anyone. I don't care about any other browsers, as this is for a private project.


I tried it out, and it worked as you said, then I tried to fix it, and came up with this:

http://jsfiddle.net/3Ve4U/1/

But when I go back to the original, it now works. Odd. Try refreshing, then doing it? Anyways, .focus() will focus the element just fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜