这是我的代码,并创建了两个切换按钮,用于更新地图和紧急按钮,但在点击更新地图后,没有任何事情发生并收到此错误。
ReferenceError:未定义切换。
代码:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, minimum-scale=1, maximum-scale=1">
<title>app template</title>
<link href="css/reset.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/jquery.mobile-1.0.1.css" />
<script type="text/javascript">
function toggle(el){
alert('hello');
if(el.className!="off")
{
el.src='images/bt2.png';
el.className="on";
}
else if(el.className=="on")
{
el.src='images/bt1.png';
el.className="off";
}
return false;
}
</script>
</head>
<body>
<div class="wrapper">
<!-- header start -->
<div class="top">
<div class="inner-top-left"><a href="#"><img src="images/arrow.png" alt="" ></a></div>
<div class="inner-top-right">Setting</div>
<div class="clear"></div>
</div>
<!-- header end -->
<!-- content start -->
<div class="setting-bg">
<div class="setting-wrapper">
<div class="contenair">
<div class="setting-left">Updating Map</div>
<div class="setting-right"><input type="image" src="images/bt2.png" width="41" height="15" class="off" onclick="toggle(this)"/> </div>
<div class="clear"></div>
</div>
<div class="contenair">
<div class="setting-left">Panic Button</div>
<div class="setting-right"><img src="images/bt2.png" width="41" height="15"></div>
<div class="clear"></div>
</div>
</div>
</div>
<!-- content end -->
<!-- bottom start -->
<div class="bottom">
<div class="bottom-btn1"><a href="setting.html"><img src="images/settings39.png" alt=""></a></div>
<div class="bottom-btn2"><a href="#" onclick="myFunction()"><img src="images/magnifier5.png" alt=""></a></div>
<div class="bottom-btn3"><a href="area.html"><img src="images/folder5.png" alt="" ></a></div>
<div class="bottom-btn4"><a href="GoogleMapDirections.html"><img src="images/map2.png" alt=""></a></div>
<div class="clear"></div>
</div>
<!-- bottom end -->
</div>
</body>
<script type="text/javascript" src="js/jquery-1.6.4.js"></script>
<!-- Cordova-1.5.0.js file will be here -->
<script type="text/javascript" src="js/cordova-1.5.0.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script src="helloresponse.js"></script>
</html>
加载页面后还有另一个错误:
未捕获的SyntaxError:意外的令牌ILLEGAL setting.html:27