Jquery: how to show additional text when a user clicks into a form field
I am new to Jquery and am trying to find a way to show additional text when a user clicks into a form.
The input field looks like this: <input class="fee开发者_开发百科d" id="post_title" name="post[title]" size="100" rows="20" type="text class="title_search"">
and the the rest of the text is contained with a <div class = "post-input">
Any help pointing me in the right direction would be much appreciated :)
$('input').focusin(function() {
$('div').show();
});
// Hide the text once you are out of the input
$('input').focusout(function() {
$('div').hide();
});
This is the basic idea. http://api.jquery.com/focusin/
$('#post_title').click(function(){
$(this).next('.post-input').html('hey! you clicked the input!');
});
//asuming the div is next to the input, if not i suggest placing an id to it, too.
and if there was alredy text in the div and you just want to show it
$('#post_title').click(function(){
$(this).next('.post-input').show();
});
$('.feed').click(function() {
$('.post-input').show();
}
精彩评论