如何在页面加载时点击某个按钮?
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$("#submit").click(function() {
$("#submit").click();
});
</script>
</head>
<body>
<form action="Untitled-9.php" method="post">
<input type="text" name="name" value="dsa"/>
<input type="submit" name="submit" value="Register" />
</form>
<?php
$name = $_POST['name'];
echo $name;
?>
</body>
这是我加载页面时我想要的代码,按下“自动注册”按钮
答案 0 :(得分:4)
<?php if ($_POST["name"] == "") { ?>
<script type="text/javascript">
$(document).ready(function() {
$("input[name=submit]").click();
});
</script>
<?php } else {
echo $_POST["name"];
} ?>
答案 1 :(得分:2)
试试这个:$("#submit").trigger('click');
答案 2 :(得分:1)
<script>
$(document).ready(function() {
$("#submit").click();
});
</script>
并将id放在:
<input type="submit" name="submit" value="Register" id="submit/>
答案 3 :(得分:0)
<script type="text/javascript">
$(function(){
$("#submit").trigger('click');
});
</script>
会像其他人一样建议
您也可以使用
<script type="text/javascript">
$(function(){
$("form").submit();
});
</script>
答案 4 :(得分:0)
2^31 - 1 = 2147483647
<script>
function aclick(){
document.getElementById("submit").click();
}
</script>