『壹』 怎樣用js設計 點擊某個按鈕,就可以改變文本框的顏色
以下是改變文本框字體的顏色!<br><input name="test" type="text" id="test" value="點擊按鈕看我變化"><br><input name="a" type="button" id="a" tvalue="black" value="黑色" onclick="document.getelementbyid('test').style.color=document.getelementbyid('test').tvalue=this.tvalue;"><br><input name="b" type="button" id="b" tvalue="red" value="紅色" onclick="document.getelementbyid('test').style.color=document.getelementbyid('test').tvalue=this.tvalue;"><br><input name="c" type="button" id="d" tvalue="green" value="綠色" onclick="document.getelementbyid('test').style.color=document.getelementbyid('test').tvalue=this.tvalue;"><br><input name="e" type="button" id="e" tvalue="green" value="獲取文本框顏色屬性值" onclick="alert(!document.getelementbyid('test').tvalue?null:document.getelementbyid('test').tvalue)"> <br><br>如果是要改變文本框背景色的話就用以下的!<br><input name="test" type="text" id="test" value="點擊按鈕看我變化"><br><input name="a" type="button" id="a" tvalue="black" value="黑色" onclick="document.getelementbyid('test').style.background=document.getelementbyid('test').tvalue=this.tvalue;"><br><input name="b" type="button" id="b" tvalue="red" value="紅色" onclick="document.getelementbyid('test').style.background=document.getelementbyid('test').tvalue=this.tvalue;"><br><input name="c" type="button" id="d" tvalue="green" value="綠色" onclick="document.getelementbyid('test').style.background=document.getelementbyid('test').tvalue=this.tvalue;"><br><input name="e" type="button" id="e" tvalue="green" value="獲取文本框顏色屬性值" onclick="alert(!document.getelementbyid('test').tvalue?null:document.getelementbyid('test').tvalue)">
『貳』 用js怎樣改變輸入框邊框的顏色
<%@pagelanguage="java"import="java.util.*"pageEncoding="GBK"%>
<%
Stringpath=request.getContextPath();
StringbasePath=request.getScheme()+"://"
+request.getServerName()+":"+request.getServerPort()
+path+"/";
%>
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
<html>
<head>
<basehref="<%=basePath%>">
<title>JS修改背景</title>
<scripttype="text/javascript">
functionJS(){
document.addmemeber("form1").memberName("int1").style.background='#eeeeee';
}
functionhid(){
varvalue=document.getElementByIdx_x("h").value;
alert(value);
}
</script>
</head>
<body>
<formaction=""name="form1">
<inputtype="text"name="int1"value=""onclick="JS();"/><br/>
<inputtype="hidden"id="h"name="h"value="隱藏"/>
<inputtype="button"value="按鈕"onclick="hid();"/>
</form>
</body>
</html>
『叄』 如何用javascript設置圖片的邊框顏色
<script type="text/javascript">
function imgborder(){
//頁面中第n個圖片的邊框
document.getElementsByTagName('img')[n].style.border="1px red solid";
//指定id圖片的邊框
//document.getElementById('aa').style.border="1px red solid";
//某元素下第n個圖片的邊框
//document.getElementById('bb').getElementsByTagName('img')[n].style.border="1px red solid";
}
window.onload=imgborder;</script>
『肆』 myeclipse jsp 提示框顏色怎麼設置!
jsp 提示框顏色設置方法:
jsp中可以嵌入通用的js寫的彈出框提示,只要根據不同場景傳不同參數就可以了。
參考代碼如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>彈出窗口(可拖動,背景灰色透明)</title>
<script type="text/javascript">
<!--
/*FileName:AlertMsg.js
title:提示標題
content:提示的內容*/
document.write("<style type=\"text/css\">*{padding:0; margin:0}.close{float:right;cursor:default}</style>")
function $(id){ return document.getElementById(id)}
function AlertMsg(title,content){
var msgw,msgh,msgbg,msgcolor,bordercolor,titlecolor,titlebg,con;
con = "<form><table style='margin:10px 15px 15px 15px; border:0;'><tr><th style='border:0; line-height:22px; padding:3px 0; vertical-align:top;font-weight:bold;'>分類:</th><td style='border:0; line-height:22px; padding:3px 0; vertical-align:top;width:75%;'><input type='text' name='typename' size='20'/></td></tr><tr><th></th><td style='border:0; line-height:22px; padding:3px 0; vertical-align:top;width:75%;'><button style='line-height:normal;' type='submit' onclick='return submitform()'>確定</button><button style='line-height:normal;' type='reset'>取消</button></td></tr></table></form>";
//彈出窗口設置
msgw = 300; //窗口寬度
msgh = 150; //窗口高度
msgbg = "#FFF"; //內容背景
msgcolor = "#000"; //內容顏色
bordercolor = "#000"; //邊框顏色
titlecolor = "#FFF"; //標題顏色
titlebg = "#369"; //標題背景
//遮罩背景設置
var sWidth,sHeight;
sWidth = screen.availWidth;
sHeight = document.body.scrollHeight;
//創建遮罩背景
var maskObj = document.createElement("div");
maskObj.setAttribute('id','maskdiv');
maskObj.style.position = "absolute";
maskObj.style.top = "0";
maskObj.style.left = "0";
maskObj.style.background = "#777";
maskObj.style.filter = "Alpha(opacity=30);";
maskObj.style.opacity = "0.3";
maskObj.style.width = sWidth + "px";
maskObj.style.height = sHeight + "px";
maskObj.style.zIndex = "10000";
document.body.appendChild(maskObj);
//創建彈出窗口
var msgObj = document.createElement("div")
msgObj.setAttribute("id","msgdiv");
msgObj.style.position ="absolute";
msgObj.style.top = (screen.availHeight - msgh) / 4 + "px";
msgObj.style.left = (screen.availWidth - msgw) / 2 + "px";
msgObj.style.width = msgw + "px";
msgObj.style.height = msgh + "px";
msgObj.style.fontSize = "12px";
msgObj.style.background = msgbg;
msgObj.style.border = "1px solid " + bordercolor;
msgObj.style.zIndex = "10001";
//創建標題
var thObj = document.createElement("div");
thObj.setAttribute("id","msgth");
thObj.className = "DragAble";
thObj.style.cursor = "move";
thObj.style.padding = "4px 6px";
thObj.style.color = titlecolor;
thObj.style.background = titlebg;
var titleStr = "<a class='close' title='關閉' style='cursor:pointer' onclick='CloseMsg()'>關閉</a>"+"<span>"+ title +"</span>";
thObj.innerHTML = titleStr;
//創建內容
var bodyObj = document.createElement("div");
bodyObj.setAttribute("id","msgbody");
bodyObj.style.padding = "10px";
bodyObj.style.lineHeight = "1.5em";
bodyObj.innerHTML = con;
var txt = document.createTextNode(content)
bodyObj.appendChild(txt);
//生成窗口
document.body.appendChild(msgObj);
$("msgdiv").appendChild(thObj);
$("msgdiv").appendChild(bodyObj);
}
function CloseMsg(){
//移除對象
document.body.removeChild($("maskdiv"));
$("msgdiv").removeChild($("msgth"));
$("msgdiv").removeChild($("msgbody"));
document.body.removeChild($("msgdiv"));
}
//拖動窗口
var ie = document.all;
var nn6 = document.getElementById&&!document.all;
var isdrag = false;
var y,x;
var oDragObj;
function moveMouse(e) {
if (isdrag) {
oDragObj.style.top = (nn6 ? nTY + e.clientY - y : nTY + event.clientY - y)+"px";
oDragObj.style.left = (nn6 ? nTX + e.clientX - x : nTX + event.clientX - x)+"px";
return false;
}
}
function initDrag(e) {
var oDragHandle = nn6 ? e.target : event.srcElement;
var topElement = "HTML";
while (oDragHandle.tagName != topElement && oDragHandle.className != "DragAble") {
oDragHandle = nn6 ? oDragHandle.parentNode : oDragHandle.parentElement;
}
if (oDragHandle.className=="DragAble") {
isdrag = true;
oDragObj = oDragHandle.parentNode;
nTY = parseInt(oDragObj.style.top);
y = nn6 ? e.clientY : event.clientY;
nTX = parseInt(oDragObj.style.left);
x = nn6 ? e.clientX : event.clientX;
document.onmousemove = moveMouse;
return false;
}
}
document.onmousedown = initDrag;
document.onmouseup = new Function("isdrag=false");
//-->
</script>
</head>
<body>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr >
<td height="100" align="center" >
<p><a href="javascript:AlertMsg("溫馨提示",'')">點我試試!</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
『伍』 javascript彈出框的背景顏色
下面那段代碼
嵌了個frame到頁面
上面是一個
player/close.htm或者player/index.htm的頁
下面是個love.html的頁
上面的問題
alert('非法的園長名稱!');"
彈出之前加一句腳本 這樣
document.body.style.backgroundColor='#000',alert('非法的園長名稱!');
『陸』 myeclipse 里我安裝了一個 js提示的一個插件 , 給js設置好了背景顏色 ,
方法如下:
依次點擊Window--->Preferences---》Myeclipse----》Files and Editors -->javascript ---》Editor --->
Syntax Coloring在上面框中選擇Background--》Script region background
然後點擊旁邊的color就可以修改頁面javascript中的背景顏色了
『柒』 js怎麼實現文本框中的顏色變化
可以通過css進行設置,比如把文本框的字體顏色設成紅色,則對應的css代碼為,color:red;
『捌』 JS怎麼控制input框的背景顏色
通過設置backgroundColor樣式進行控制
1、頁面定義一個input節點
<divid='aDiv'>
<inputtype="text"id="a"onblur="fun(this)">//定義onblur事件調用改變背景
</div>
2、添加改變背景的函數
<scripttype="text/javascript">
functionfun(obj){
obj.style.backgroundColor="#ff0000";
//這里獲取到了該節點,怎麼讓該text框背景顏色改變,變紅色也行。即:background-color屬性顏色
}
</script>
『玖』 js 修改邊框顏色
不要混合html屬性和css屬性(測試發現似乎只有IE會這樣)。
在table里添加屬性style="border-color:#00F",然後去掉bordercolor屬性:
<script type="text/javascript">
function borderit(which){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
which.style.borderColor="FF0000";
}
}
</script>
</head>
<table border="3" onmousemove="borderit(this)" style="border-color:#00F" cellpadding="0" cellspacing="0">
<tr><td>2345345345</td></tr>
</table>
『拾』 此彈出菜單的JS文件如何修改彈出的框的背景顏色,框體長度等
你好
修改彈出框寬和高的代碼和彈出框背景顏色都在index.html的第23行
.dropMenu{position:absolute;top:0;z-index:100;visibility:hidden;margin-top:-2px;border:1pxsolid#0e2c5e;border-top:0;background-color:#cbdef4;padding:4px;width:260px;}
改背景顏色修改background-color參數即可
修改寬修改width參數即可,修改高在上面的代碼加height:200px即可
試例代碼,高寬400,背景紅色
.dropMenu{position:absolute;top:0;z-index:100;visibility:hidden;margin-top:-2px;border:1px solid #0e2c5e;border-top:0;padding:4px;
background-color:red;
width:400px;
height:400px
}
效果