找一个js效果,点击 加减 会添加删除

JavaScript016

找一个js效果,点击 加减 会添加删除,第1张

自己拼一个吧,点击“+”号的时候,append一组数据,记得要有不一样的id;

点击“-”号的时候需要判断当前宝贝数量是否为1,如果是1,不让减,如果不是,那么移除一组,根据id移除。

没里面的图,但想来你也能知道图是什么

<!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/htmlcharset=gb2312" />

<title>无标题文档</title>

<script>

function fang(num)

{

var tra0000="tra" + num

var jia0000="jia" + num

var jian0000="jian" + num

var x=document.getElementById(tra0000)

var jia=document.getElementById(jia0000)

var jian=document.getElementById(jian0000)

x.style.display=''

jia.style.display='none'

jian.style.display=''

}

function suo(num)

{

var tra0000="tra" + num

var jia0000="jia" + num

var jian0000="jian" + num

var x=document.getElementById(tra0000)

var jia=document.getElementById(jia0000)

var jian=document.getElementById(jian0000)

x.style.display='none'

jia.style.display=''

jian.style.display='none'

}

</script>

</head>

<body>

<table width="200" border="0" align="right" cellpadding="0" cellspacing="0">

<tr><td width="13" height="20" background="images/00xu3jiao.gif"></td>

<td align="left" width="20"><img name="" border="0" src="images/00xujia.jpg" width="17" height="20" alt="" id="jia1" onclick="fang(1)"/><img name="" src="images/00xujian.jpg" width="17" height="20" alt="" id="jian1" onclick="suo(1)" style="display:none"/></td>

<td align="left" valign="middle">资料管理</td>

</tr>

<tr id="tra1" style="display:none"><td height="60"background="images/00xushuxian.gif"></td><td background="images/00xu3jiaoduo.gif"></td>

<td><table width="150" height="60" border="0" align="left" cellpadding="0" cellspacing="0">

<tr>

<td align="left" valign="bottom"><a href="pxgl_base.php" target="youcedisplay" >基本信息</a></td>

</tr>

<tr>

<td align="left" valign="bottom"><a href="pxgl_pic.php" target="youcedisplay">机构图片</a></td>

</tr>

<tr>

<td align="left" valign="bottom"><a href="pxgl_index.php" target="youcedisplay">预览页面</a></td>

</tr>

</table></td>

</tr>

<!----->

<tr><td width="13" height="20" background="images/00xu3jiao.gif"></td>

<td align="left" width="20"><img name="" border="0" src="images/00xujia.jpg" width="17" height="20" alt="" id="jia2" onclick="fang(2)"/><img name="" src="images/00xujian.jpg" width="17" height="20" alt="" id="jian2" onclick="suo(2)" style="display:none"/></td>

<td align="left" valign="middle">培训课程</td>

</tr>

<tr id="tra2" style="display:none"><td height="40"background="images/00xushuxian.gif"></td><td background="images/00xu3jiaoduo.gif"></td>

<td><table width="150" height="40" border="0" align="left" cellpadding="0" cellspacing="0">

<tr>

<td align="left" valign="bottom"><a href="pxgl_add.php" target="youcedisplay" >发布培训课程</a></td>

</tr>

<tr>

<td align="left" valign="bottom"><a href="pxgl_admin.php" target="youcedisplay" >培训课程管理</a></td>

</tr>

</table></td>

</tr>

<!----->

<tr><td width="13" height="20" background="images/00xu3jiao.gif"></td>

<td align="left" width="20"><img name="" border="0" src="images/00xujia.jpg" width="17" height="20" alt="" id="jia3" onclick="fang(3)"/><img name="" src="images/00xujian.jpg" width="17" height="20" alt="" id="jian3" onclick="suo(3)" style="display:none"/></td>

<td align="left" valign="middle">帐号管理</td>

</tr>

<tr id="tra3" style="display:none"><td height="40"background="images/00xushuxian.gif"></td><td background="images/00xu3jiaoduo.gif"></td>

<td><table width="150" height="40" border="0" align="left" cellpadding="0" cellspacing="0">

<tr>

<td align="left" valign="bottom"><a href="pxgl_userup.php" target="youcedisplay" >更改用户名</a></td>

</tr>

<tr>

<td align="left" valign="bottom"><a href="pxgl_pwdup.php" target="youcedisplay" >更改密码</a></td>

</tr>

</table></td>

</tr>

<!----->

<tr><td width="13" height="20" background="images/00xubanjiao.gif"></td>

<td align="left" width="20"background="images/00xuhengxian.gif"></td>

<td align="left" valign="middle">安全退出管理中心</td>

</tr>

</table>

<p></p>

</body>

</html>

上面自己写的也不太好

建议去这个网站,连代码带运行效果都有

http://www.qpsh.com/javascript/showpage2569.htm