Question

I have this Input type submit:

<input type="submit" name="step2" id="step2" class="btn_orange" value="Continue ››">

If I do a console.log of this button .val(), I get it:

console.log($("input#step2").val());

Result: "Continuar ››"

I put the following trigger to click the button:

if($price < 1){
    echo "
        <script type=\"text/javascript\">

            $(\"input#step2\").trigger(\"click\"); 

        </script>"; // TODO
} ?>

And doesnt works. If I write this code in the inspect, it works.

Where is the problem?

Regards

Was it helpful?

Solution

$(function(){
    $(\"input#step2\").trigger(\"click\"); 
});

Makes sure the document is ready.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top