Programmatically click a button using jquery

后端 未结 2 1076
一整个雨季
一整个雨季 2021-01-03 21:54

I have this button:

相关标签:
2条回答
  • 2021-01-03 22:42

    Add a small timeout:

    $(document).ready(function(){
    
        setTimeout(function(){
    
            $("#control-qid13228").click();
    
    
        },1);
    
    });
    

    https://jsfiddle.net/46my242x/1/

    or try:

    $("#control-qid13228")[0].click();
    

    https://jsfiddle.net/46my242x/2/

    This is a similar question: jQuery.trigger('click') not working

    0 讨论(0)
  • 2021-01-03 22:47

    Let's try:

    <script>
    $(document).ready(function(){
        $("#control-qid13228").click(function(){
            alert('clicked');
        });
    });                     
    </script>
    
    0 讨论(0)
提交回复
热议问题