Jquery 如何像堆栈溢出表单那样显示表单控件的UI提示?
我正在尝试在ASP.NET MVC 2应用程序上显示一些UI提示,就像编辑/填写简历时在职业网站上显示的那样:当表单控件有焦点时,在它旁边会显示一些关于如何输入所需信息的说明Jquery 如何像堆栈溢出表单那样显示表单控件的UI提示?,jquery,asp.net-mvc,user-interface,Jquery,Asp.net Mvc,User Interface,我正在尝试在ASP.NET MVC 2应用程序上显示一些UI提示,就像编辑/填写简历时在职业网站上显示的那样:当表单控件有焦点时,在它旁边会显示一些关于如何输入所需信息的说明 显示这些吸盘的最佳方法是什么…jQuery将简化这一过程,但它很容易成为标准JS 比如: $('.controlwithhinttext').focus(function() { // show hint $('#hint' + $(this).attr('hint_to_show_id')).show
显示这些吸盘的最佳方法是什么…jQuery将简化这一过程,但它很容易成为标准JS 比如:
$('.controlwithhinttext').focus(function() {
// show hint
$('#hint' + $(this).attr('hint_to_show_id')).show();
});
其中表单控件具有自定义属性,或仅使用匹配(不完全相同)ID。行中的某些内容: CSS:
.field{position:relative;}
.field-help{display:none;background:yellow;position:absolute;left:200px;top:0;}
<div class="field">
<input type="text">
<div class="field-help">Help text</div>
</div>
$('.field input').bind('focus', function(e) {
$(e.target).next('.field-help').show();
}).bind('blur', function(e) {
$(e.target).next('.field-help').hide();
})
HTML:
.field{position:relative;}
.field-help{display:none;background:yellow;position:absolute;left:200px;top:0;}
<div class="field">
<input type="text">
<div class="field-help">Help text</div>
</div>
$('.field input').bind('focus', function(e) {
$(e.target).next('.field-help').show();
}).bind('blur', function(e) {
$(e.target).next('.field-help').hide();
})
清洁你的耳朵
呃,我的意思是使用jQuery Qtip插件:
它100%地完成了您要查找的内容,而且做得非常好。匹配ID是什么意思?我的意思是将表单控件的ID用作选择器的一部分。