110,571
社区成员
发帖
与我相关
我的任务
分享
<body id="main" >
<iframe src="IframeHead.aspx" class="IframeHead"></iframe>
<br />
<iframe name="frameBody" src="IframeBody.aspx" class="IframeBody" marginwidth="0" marginheight="0" id="newFrameBody"></iframe>
</body>
//改变样式
function changeStyle()
{
var len=document.getElementsByName("tasks");
for(var i=0;i<len.length;i++)
{
var my=document.getElementById(len[i].id).id;
var pid=document.getElementById(my).parentNode.id;
var npid=document.getElementById(pid).nextSibling.id;
var cid="";
$("#"+npid).children("div").each(function(){
cid+=this.id;
});
if(len[i].checked)
{
document.getElementById(cid).className="delLine";
}else
{
document.getElementById(cid).className="";
}
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function changeStyle() {
document.getElementById("div1").className = "delLine";
}
</script>
<style type="text/css">
.delLine
{
background-color: #ff0000;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div id="div1" style="height: 100px; width: 100px;">
</div>
</form>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "changeStyle()", true);
}
}