button按钮也可以的啊,一样的使用方法啊,在js中提交的,还是说你想根据不同的按钮将form1表单提交到不同的action里?
<script type="text/javascript">
function sub(){
document.form1.submit()
}
</script>
<body>
<form action="Getvalue" method="post" name="form1">
<input type="text" name="username"><br/>
<input type="password" name="password"><br/>
<input type="button" value="button测试" onclick="sub()">
</form>
</body>
可以手动构建一个FormData进行表单提交,代码如下:
var form = new FormData()//添加参数
form.append('name', 'jack')
form.append('age', 20)
//使用xmlhttprequest发起请求
var xhr = new XMLHttpRequest()
xhr.open('post', '这里添上请求的url', true)
xhr.onreadystatechange = function() {
if(xhr.readyState == 4) {
//成功
}
}
//执行请求
xhr.send(form)
首先,把CSS和JS标签style属性对照表了解了:CSS 和 JavaScript 标签 style 属性对照表:
盒子标签和属性对照
CSS语法(不区分大小写) JavaScript语法(区分大小写)
border border
border-bottom borderBottom
border-bottom-color borderBottomColor
border-bottom-style borderBottomStyle
border-bottom-width borderBottomWidth
border-colorborderColor
border-left borderLeft
border-left-color borderLeftColor
border-left-style borderLeftStyle
border-left-width borderLeftWidth
border-right borderRight
border-right-color borderRightColor
border-right-styleborderRightStyle
border-right-width borderRightWidth
border-style borderStyle
border-top borderTop
border-top-color borderTopColor
border-top-style borderTopStyle
border-top-widthborderTopWidth
border-width borderWidth
clear clear
float floatStyle
margin margin
margin-bottom marginBottom
margin-left marginLeft
margin-rightmarginRight
margin-top marginTop
padding padding
padding-bottom paddingBottom
padding-leftpaddingLeft
padding-right paddingRight
padding-top paddingTop
颜色和背景标签和属性对照
CSS 语法(不区分大小写) JavaScript 语法(区分大小写)
background background
background-attachment backgroundAttachment
background-colorbackgroundColor
background-imagebackgroundImage
background-position backgroundPosition
background-repeat backgroundRepeat
color color
样式标签和属性对照
CSS语法(不区分大小写) JavaScript 语法(区分大小写)
display display
list-style-type listStyleType
list-style-imagelistStyleImage
list-style-position listStylePosition
list-style listStyle
white-space whiteSpace
文字样式标签和属性对照
CSS 语法(不区分大小写) JavaScript 语法(区分大小写)
fontfont
font-family fontFamily
font-size fontSize
font-style fontStyle
font-variantfontVariant
font-weight fontWeight
文本标签和属性对照
CSS 语法(不区分大小写) JavaScript 语法(区分大小写)
letter-spacing letterSpacing
line-break lineBreak
line-height lineHeight
text-align textAlign
text-decoration textDecoration
text-indent textIndent
text-justifytextJustify
text-transform textTransform
vertical-align verticalAlign
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>New Document </TITLE>
</HEAD>
<script language="javascript">
function validate(){
if (document.all("name").value == ""){
document.all("name").style["borderColor"]="red"//就是这里
return
}
}
</script>
<BODY>
<input type="text" name="name" >
</BODY>
</HTML>