Here是小提琴。我正在尝试在输入标签中使用onFocus使文本框发光0 0 30px #96f226
,但是您知道单击文本框时边框会改变吗?那是我希望它发光的时候。 JS遵循我所知道的所有内容,但是不起作用。
JS(仅针对问题):
function input() {
var x = document.getElementById('input');
x.style.box-shadow = '0 0 30px #96f226';
}
最佳答案
将box-shadow
更改为boxShadow
。尝试使用此代码来切换焦点
function inputfocus(x) {
x.style.boxShadow = '0 0 30px #96f226';
}
function inputblur(x) {
x.style.boxShadow = 'none';
}
<input type="text" onFocus="inputfocus(this)" onblur="inputblur(this)">
jsfiddle
的CSS
#input:focus{
box-shadow: 0 0 30px #96f226;
-webkit-box-shadow: 0 0 30px #96f226;
-moz-box-shadow: 0 0 30px #96f226;
}
关于javascript - onFocus无法使用javascript函数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17823197/