用js怎样改变输入框边框的颜色??

JavaScript023

用js怎样改变输入框边框的颜色??,第1张

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>

<%

 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>JS修改背景</title>

  <script type="text/javascript">

function JS() {

 document.addmemeber("form1").memberName("int1").style.background = '#eeeeee'

}

function hid(){

 var value = document.getElementByIdx_x("h").value 

 alert(value) 

 

}

</script>

 </head>

 <body>

  <form action="" name="form1">

   <input type="text" name="int1" value="" onclick="JS()"/><br/>

   <input type="hidden" id="h" name="h" value="隐藏"/>

   <input type="button" value="按钮" onclick="hid()"/>

  </form>

 </body>

</html>

我的做法是:

假如你所说的那段文字放在一个DIV里,DIV的class属性就是定义DIV容器里的元素的样式的,id就是给javascript获取到该元素的。获取到之后通过改class属性,就相当于改了div里的样式

<html>

<head>

<style type="text/css">

.style1{font-size:12pxfont-weight:blodcolor:red}

.style2{font-size:14pxfont-weight:blodcolor:blue}

</style>

<script language="javascript" type="text/javascript">

function change(){

document.getElementById("myword").className= "style2"

}

</script>

</head>

<body>

<div><a href="#" class="style1" id="myword" onclick="change()">我是DIV里的文字</a></div>

</body>

</html>