JavaScript更改提交表单上的输入样式
我试图在提交表单时在输入的背景下制作相同的加载动画 css: javascript:JavaScript更改提交表单上的输入样式,javascript,php,html,css,Javascript,Php,Html,Css,我试图在提交表单时在输入的背景下制作相同的加载动画 css: javascript: function onSearch(){ document.getElementById("loadingAnimation").className += " inputLoading"; } html: 搜寻 问题是,这在IE11和Firefox 26中有效,但在Chrome 33中不起作用。在Chrome中,表单提交后没有动画。gif的URL是正确的。所以我试图解决这个问题,但没有运气。奇怪的
function onSearch(){
document.getElementById("loadingAnimation").className += " inputLoading";
}
html:
搜寻
问题是,这在IE11和Firefox 26中有效,但在Chrome 33中不起作用。在Chrome中,表单提交后没有动画。gif的URL是正确的。所以我试图解决这个问题,但没有运气。奇怪的是,如果我只改变输入的背景色,它将在任何地方都能工作
有什么想法吗
更新:我已经在几台电脑上测试过了,现在我可以告诉大家,只有Chrome没有问题。在某些计算机上,即使在FF或IE上也无法工作。请确保您的chrome浏览器上是否安装了任何类型的adBlock扩展或图像块扩展。如果没有显示图像,这可能是原因之一。是否将
输入加载
类添加到chrome中的输入
元素中?@rakesharma tnx for link。将读取它。@Pattle developer tools在输入中正确显示类。
function onSearch(){
document.getElementById("loadingAnimation").className += " inputLoading";
}
<form action="index.php" method="get" onsubmit="onSearch()">
<input type="text" id="loadingAnimation" class="form-control">
<button type="submit">Search</button>
</form>