我们使用jQuery将显示,隐藏和切换功能应用于图像和文本。该技术已用于许多语言中,以创建应用程序和网站等。
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="test.js"></script>
<script type="text/javascript">
$(document).ready(function ()
{
// by using the 'time' parameter we can set the duration of the animation
$('#hide').click(function()
{
$('img').hide(5000)
})
// by specifying 'fast' it will show the image quickly
$('#show').click(function()
{
$('img').show('fast')
})
// by specifying 'slow' it will show or hide the image slowly
$('#toggle').click(function()
{
$('img').toggle('slow')
})
})
</script>
</head>
<body>
<center>
<img src="images/1.jpg" width="400" height="400">
<br>
<button id="hide">Hide</button>
<button id="show">Show</button>
<button id="toggle">Hide/Show</button>
</center>
</body>
</html>