我试过.click(),显然不是这样。如何模拟点击并使网页功能就像点击它一样?
答案 0 :(得分:2)
试试这个:
$( "#foo" ).on( "click", function() {
alert( $( this ).text() );
});
$( "#foo" ).trigger( "click" );
更多信息请参阅:jQueryDocumentation
答案 1 :(得分:1)
$(document).ready(function(){
$("p").click();
alert("The paragraph was clicked.");
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<p> paragraphp will be click when the page loads </p>
&#13;