[英]jquery toggle disappear quickly after clicking button
this is my code.. 这是我的代码。
<div id="hint-toggle" class="ui-body ui-body-e" style="display: none">
<p>No Hints available right now,check it later</p>
</div>
<button id="show-hint" onclick="showHint();"type="submit" data-inline="true" data-theme="c">Show Hint</button>
<script type="text/javascript">
function showHint(event){
$("#hint-toggle").toggle();
}
</script>
After clicking show hint
button it appear but within 2 sec it'll disappear.. did i miss anything in my code?? 单击
show hint
按钮后,它会出现,但在2秒钟之内会消失..我是否错过了代码中的任何内容? please help me.i want to show hint-toggle
till i again press show hint
button. 请帮助我。我想显示
hint-toggle
直到我再次按show hint
按钮。
FYI: http://jsfiddle.net/shreeramns/rUKbh/ 仅供参考: http : //jsfiddle.net/shreeramns/rUKbh/
To prevent the submit button from taking its default action, you should prevent the default action: 为了防止“提交”按钮采取其默认操作,您应阻止该默认操作:
<button id="show-hint" onclick="showHint(event);" type="submit" data-inline="true" data-theme="c">Show Hint</button>
Notice how we pass in the event
object in the JS 注意我们如何在JS中传递
event
对象
function showHint(event) {
event.preventDefault();
$("#hint-toggle").toggle();
}
Demo: http://jsfiddle.net/DDsZn/ 演示: http : //jsfiddle.net/DDsZn/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.