首先呢,说一下,刚学jQuery一天,身边没有老师,虽然这手册是最好的老师,不过不能说话,下面是我根据手册上说的,写出来的代码,但是运行不对的,因为没有button。我主要想请达人们讲下,这个button怎么写,简单的说就是如何完善这个程序;并且,请附带讲一下那个“toggle(flip++%2==0);”实现了什么样的功效,是如何操作的。 谢谢。<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="F:/WEB/JQuery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
var flip=0;
$("button").click(function(){
$("p").toggle(flip++%2==0);
});
});
</script>
</head><body>
<p style="display:none">HELLO</p>
<p style="display:block">HELLO AGAIN</p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="F:/WEB/JQuery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
var flip=0;
$("button").click(function(){
$("p").toggle(flip++%2==0);
});
});
</script>
</head><body>
<p style="display:none">HELLO</p>
<p style="display:block">HELLO AGAIN</p>
</body>
</html>
解决方案 »
- jquery easyui-combobox 添加选项
- yui插件不能正确显示
- innerHtml嵌套struts2标签
- 在一个div里设置属性style="display:none" 为什么js就获取不到文本框里的值
- 急急!!!请教一个简单的背景更换JS..在线等
- 定义一个对象时:var O=new Object() 与 var O={}两种定义在哪里不一样
- 下拉菜单,请帮我看看坐标有啥不对???
- 白送分啦,简单的问题,关于滚动条!
- 啊,救命!!
- 请问web应用中cookie什么时候判断?
- 如何让iframe中的页面弹出的div遮罩将iframe也罩住?
- 用过My97DatePicker请进
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(function(){
var flip = 0;
$(":input[name='but_name']").click(function(){
$('p').toggle(flip++ %2 == 0);
//toggle():显示或者隐藏,如果现在是显示,再点击就隐藏,否则反之
//flip++ %2 == 0 :判断条件
});
});
</script>
</head>
<body>
<p style="display:none">HELLO</p>
<p style="display:block">HELLO AGAIN</p>
<input type="button" name="but_name" value="button">
</body>
</html>