jQuery 中的输入 [type="submit"]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12659959/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
input[type="submit"] in jQuery
提问by dodancs
how to do this:
这该怎么做:
input[type="submit"] {
color:green;
}
in jQuery?
在 jQuery 中?
$('input[type="submit"]').css("color","green");
is not working :|
不工作:|
回答by Miha Rekar
Probably because it is triggering before jQuery is "ready". Try this:
可能是因为它在jQuery“准备好”之前触发。尝试这个:
$(function() {
$('input[type="submit"]').css("color","green");
});
回答by StaticVariable
Use a simple css instead of javascript
使用简单的 css 而不是 javascript
input[type="submit"]{
color: green;
cursor: pointer;
font: bold 12px Helvetica,Arial,sans-serif;
}
回答by Database_Query
But the jquery must load it before this
但是 jquery 必须在此之前加载它
You can also do this by adding the id or class in submit
您也可以通过在提交中添加 id 或 class 来做到这一点
$('#submit_id/.submit_class').css("color","green");
回答by someone_alive
Try adding this:
尝试添加这个:
$("form").submit(function(event) {
event.preventDefault();
});
It may be that your original code is working, but since the page re-loads normally when you click on a submit button in a form, that action is preventing you from seeing your change.
可能是您的原始代码正在运行,但是由于当您单击表单中的提交按钮时页面会正常重新加载,因此该操作会阻止您看到您的更改。