<div class="aa">
<DL class=v1>
<DT>aaaa</DT>
</DL>
<DL class=v2>
<DT>aaaa </DT>
</DL>
<DL class=v3>
<DT>aaaa </DT>
</DL>
<DL class=v4>
<DT>aaaa </DT> </DL>
</DIV>
4句合并一句,因为就V1-V4不同,所以怎么写一个JS啊
<DL class=v1>
<DT>aaaa</DT>
</DL>
<DL class=v2>
<DT>aaaa </DT>
</DL>
<DL class=v3>
<DT>aaaa </DT>
</DL>
<DL class=v4>
<DT>aaaa </DT> </DL>
</DIV>
4句合并一句,因为就V1-V4不同,所以怎么写一个JS啊
如果是用动态生成dl的话,用insertAdjestHtml方法就可以了。
<html>
<head>
<link href="a.css" rel="stylesheet" type="text/css" />
</head>
<body><div class="aa" id='d1'>
<DL>
<DT>aaaa </DT>
</DL>
<DL>
<DT>aaaa </DT>
</DL>
<DL>
<DT>aaaa </DT>
</DL>
<DL>
<DT>aaaa </DT> </DL>
</DIV>
<script>
var objList = document.getElementById("d1").getElementsByTagName("DL");
for(var i=0;i<objList.length;i++)
{
objList[i].className = "v" + (i+1);
}
</script>
<body>
</head>
.v1
{
color:green;
}
.v2
{
color:red;
}
.v3
{
color:blue;
}
.v4
{
color:orange;
}