现在的位置: 首页 > 综合 > 正文

javascript(二)

2013年10月12日 ⁄ 综合 ⁄ 共 850字 ⁄ 字号 评论关闭

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>two</title>
        <link rel="stylesheet" type="text/css" href="styles.css">
        <style type="text/css">
            div{
                background-color:red;
                width:250px;
                height:250px
            }
            
        </style>
        <script type="text/javascript">
            function changeColor(){
                var myDiv=document.getElementById("myDiv");
                myDiv.style.backgroundColor="blue";
            
            }
        
        </script>
  </head>
 
  <body>
    <div id="myDiv" onclick="changeColor();">
        
    </div>
  </body>

</html>

改变 页面中元素的样式

抱歉!评论已关闭.