我是Jquery的新手,我正试图在用户点击表单时找到显示其他文字的方法。
输入字段如下所示:<input class="feed" id="post_title" name="post[title]" size="100" rows="20" type="text class="title_search"">
,文本的其余部分包含<div class = "post-input">
非常感谢任何帮助我指向正确方向的帮助:)
答案 0 :(得分:2)
$('input').focusin(function() {
$('div').show();
});
// Hide the text once you are out of the input
$('input').focusout(function() {
$('div').hide();
});
这是基本的想法。 http://api.jquery.com/focusin/
答案 1 :(得分:1)
$('#post_title').click(function(){
$(this).next('.post-input').html('hey! you clicked the input!');
});
//假设div在输入旁边,如果不是,我也建议给它一个id。
如果div中已有文字,你只想展示它
$('#post_title').click(function(){
$(this).next('.post-input').show();
});
答案 2 :(得分:0)
$('.feed').click(function() {
$('.post-input').show();
}