Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 更改<;的背景色;面积>;在ASP.NET中加载页面时_Javascript_Jquery_Css_Asp.net - Fatal编程技术网

Javascript 更改<;的背景色;面积>;在ASP.NET中加载页面时

Javascript 更改<;的背景色;面积>;在ASP.NET中加载页面时,javascript,jquery,css,asp.net,Javascript,Jquery,Css,Asp.net,我有,其中包含不同地区的图像。我需要在加载页面时更改不同热点的背景色。背景颜色信息存储在SQL Server表中。加载页面时,我检索颜色并将其存储在列表中。使用JavaScript,我需要更改特定元素的背景色 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Indicator_Color_Map.WebForm1" %> <!DOCTYPE html P

我有
,其中包含不同地区的图像。我需要在加载页面时更改不同热点的背景色。背景颜色信息存储在SQL Server表中。加载页面时,我检索颜色并将其存储在列表中。使用JavaScript,我需要更改特定
元素的背景色

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Indicator_Color_Map.WebForm1" %>

<!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 runat="server">
    <title></title>
    <%--<style>
    area
    {
        background-color:Red;
    }
    </style>--%>
    <script type="text/javascript">
        function setColor() {
            document.getElementById("area1").style.background-color = "green";
        }
    </script>
</head>
<body onload="setColor()">
    <form id="form1" runat="server" >
    <div>
    <img src="jammu.jpg" alt="Planets" usemap="#planetmap" style="height: 434px; width: 369px">
    <map  id="map1" name="planetmap">   
  <area shape="rect" coords="0,0,82,126" href="" alt="Sun" id="area1"  >
  <area shape="circle" coords="90,58,3" href="" alt="Mercury" id="2">
  <area shape="circle" coords="124,58,8" href="" alt="Venus" id="3">
</map>
    </div>
    </form>
</body>
</html>

函数setColor(){
document.getElementById(“area1”).style.background-color=“绿色”;
}
我尝试使用ImageMap控件,但无法将样式应用于不同的坐标


任何其他第三方控件是否有用?

使用
样式.背景色
而不是
样式.背景色

document.getElementById("area1").style.backgroundColor = "green";

试试这个
backgroundColor
而不是
backgroundColor
我确实用了同样的颜色,但它不起作用。它对你有用吗?