[英]show or hide button using jquery?
I have two button start and stop. 我有两个按钮启动和停止。 on page load stop button hide and start button show. 页面上的加载停止按钮隐藏和开始按钮显示。 when i click start button this button hide and stop button show. 当我单击开始按钮时,此按钮将隐藏并显示停止按钮。
i am using .hide()
method. 我正在使用.hide()
方法。
Jquery Code: jQuery代码:
$(window).load(function ()
{
$('#stop').hide();
});
It's working but issue is when page load this (stop button) will show for a second(like a blink) and then hide. 它正在工作,但问题是在页面加载时,此按钮(停止按钮)将显示一秒钟(例如闪烁),然后隐藏。 i want to hide completely mean i don't want to show stop button when page load. 我想完全隐藏意味着我不想在页面加载时显示停止按钮。
Hide it once only the button has loaded, not the whole window. 仅在按钮加载后隐藏它,而不是整个窗口都隐藏。
$("#stop").load(function() {
$(this).hide();
});
Otherwise you can always use CSS to hide it with display:none;
否则,您始终可以使用CSS使用display:none;
隐藏它display:none;
也许使用CSS:
#stop { display: none; }
It is because you have used the load event handler, So till all the resources of the page is loaded the script is not executed. 这是因为您使用了load事件处理程序,因此,直到页面的所有资源都加载完毕,脚本才会执行。
One possible solution is to use a css rule, with the id selector to hide the element like 一种可能的解决方案是使用css规则,并使用id选择器隐藏元素,例如
#stop{display: none;}
$(document).ready(function () {
$("#btnStop").click(function (e) {
e.preventDefault();
$(this).hide();
$("#btnPlay").show();
})
$("#btnPlay").click(function (e) {
e.preventDefault();
$(this).hide();
$("#btnStop").show();
})
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.