【发布时间】:2013-02-04 17:03:14
【问题描述】:
我需要创建一个 div,它在表单域处于活动状态时显示包含提示,而在表单域不再处于活动状态时消失。我的表单字段都有 ID,例如 #monthly_rent,而我的小费有一个 .monthly_rent_tip 类。我怎样才能让它在必要时出现和消失。
这是我目前拥有但不起作用的代码。
<script type="text/javascript">
jQuery(document).ready(function()
{
jQuery('.tip.left.monthly_rent_tip').hide(); //hide
jQuery('#monthly_rent').focus(function(){
jQuery('.tip.left.monthly_rent_tip').show(); //show
}).blur(function(){
jQuery('.tip.left.monthly_rent_tip').hide(); //hide again
});
});
</script>
提示 div 的 CSS 在这里:
.tip {
position:relative;
padding:15px;
margin:1em 0 3em;
border:5px solid #f18500;
background:#fff;
/* css3 */
-webkit-border-radius:10px;
-moz-border-radius:10px;
border-radius:10px;
}
.monthly_rent_tip {
top:1060px;
left:-130px;
}
目前这没有任何作用,谁能指出我正在犯的错误。
【问题讨论】:
-
JQuery首先将它们修复为$或jQuery -
您能添加与您的 js/css 一起使用的 html 吗?