未单击按钮时显示工具提示
Show tooltip when the button isn't clicked
我想在用户提交表单时未单击特定按钮时显示工具提示。我阻止表单提交,我只想显示工具提示,说"您应该先单击按钮"。提前谢谢。
<form id="signUpForm">
<button type="button" id="agree" class="btn btn-default" data-color="info" tabindex="7">I Agree</button>
<input type="hidden" id="hidden" value="0">
<input type="submit" id="btn-submit" value="submit">
</form>
<script>
$('#signUpForm').submit(function(e) {
if ($('#hidden').val() == '0') {
e.preventDefault();
//show the tooltip that "you first click the agree button" and fadeOut(1000)
}
});
</script>
试试这个,将按钮类型设置为按钮而不是提交:
<form id="signUpForm" >
<button type="button" id="agree" class="btn btn-default" data-color="info" tabindex="7" >I Agree</button>
<input type="hidden" id="hidden" value="0">
<input type="button" id="btn-submit" value="submit">
</form>
<script>
$('#btn-submit').click(function(e){
if($('#hidden').val()=='0'){
}
else {
$('#signUpForm').submit();
}
});
</script>
检查下面的脚本,它将帮助您显示工具提示。
<script>
$(".tooltip").hide();
$('#signUpForm').submit(function (e) {
if ($('#hidden').val() == '0') {
e.preventDefault();
//show the tooltip that "you first click the agree button" and fadeOut(1000)
$("#signUpForm").find(".tooltip").stop().fadeIn();
setTimeout(function () {
$("#signUpForm").find(".tooltip").stop().fadeOut();
}, 1000);
}
});
</script>
网页部件
<form id="signUpForm">
<button type="button" id="agree" class="btn btn-default" data-color="info" tabindex="7">I Agree</button>
<input type="hidden" id="hidden" value="0">
<input type="submit" id="btn-submit" value="submit">
<div class="tooltip">
you first click the agree button
</div>
</form>
相关文章:
- Highcharts-在单击而不是悬停时显示工具提示
- C3.js通过单击按钮显示工具提示
- 未单击按钮时显示工具提示
- 高图表在点单击时显示工具提示
- Flexslider-当鼠标悬停在点上时显示工具提示
- 高亮显示工具提示共享项,具体取决于Highcharts中悬停的系列
- 显示工具提示而不双击字段
- 在 Twitter 引导程序中自动显示工具提示,而无需放置光标
- 悬停时显示工具提示
- 隐藏 x 轴标签,但在图表.js中显示工具提示
- 突出显示工具提示中未显示名称的 3D 散点
- 如何在图像库森时更改颜色和显示工具提示
- q提示 2 - 鼠标按下以显示工具提示?鼠标向上隐藏
- D3.js水平折线图无法正确显示工具提示
- 在 d3.js 折线图中永久显示工具提示
- 如何在 SVG 上的鼠标光标旁边显示工具提示,尽管网站上有非 SVG 元素
- 高图表在类别标签悬停时显示工具提示
- 仅在完全创建时显示工具提示
- 鼠标输入时未显示工具提示
- 鼠标悬停时无法显示工具提示,jQuery1.11