[英]How to load a div using jQuery after moving the focus to an input field?
How can I load a div after moving the focus into an input field? 将焦点移动到输入字段后如何加载div? That means when my cursor is placed in an input field, I want to load a div just below the input field.
这意味着当我的光标放在输入字段中时,我想在输入字段的正下方加载一个div。 Please help me, I'm newbie in jQuery and don't know exactly how can I do this.
请帮助我,我是jQuery的新手,不知道我该怎么做。
That's fairly straightfoward with jQuery: 这与jQuery相当直接:
$('#myInput').on('focus', function(){
$(this).after('<div />').html('whatever goes in the div');
})
...though, where you get the contents for the div from is another issue. ...但是,从哪里获得div的内容是另一个问题。 Do you need to load that from the server-side?
你需要从服务器端加载吗?
Try this: 尝试这个:
$( "#target" ).focus(function() {
$( this ).after( "<div>Test</div>" );
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.