[英]onFocus not working with javascript function
Here 's the fiddle. 这是小提琴。 I'm trying to make the textbox glow
0 0 30px #96f226
using onFocus in the input tag, but you know when you click on a textbox and the border changes? 我正在尝试在输入标签中使用onFocus使文本框发光
0 0 30px #96f226
,但是您知道单击文本框时边框会改变吗? That's when I want it to glow. 那是我希望它发光的时候。 The JS follows everything I have know, but it doesn't work.
JS遵循我所知道的所有内容,但是不起作用。
JS (just for the problem): JS(仅针对问题):
function input() {
var x = document.getElementById('input');
x.style.box-shadow = '0 0 30px #96f226';
}
change box-shadow
to boxShadow
. 将
box-shadow
更改为boxShadow
。 try this code for toggling focus 尝试使用此代码来切换焦点
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)">
CSS CSS
#input:focus{
box-shadow: 0 0 30px #96f226;
-webkit-box-shadow: 0 0 30px #96f226;
-moz-box-shadow: 0 0 30px #96f226;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.