How to grab button clicked that was created dynamically

Asked

Viewed 22 times

1

Good morning.

I am creating a button dynamically via an answer from an sql.

  $this->return.='<div class="row">
                        <div class="col-xs-12 col-lg-12 col-md-12 col-sm-12">
                            <input type="button" id="btnSegundaEtapa" class="btn btn-success green pull-right" value="Proximo" name="btnSegundaEtapa">
                        </div>

                    </div>';

There I am taking it this way

$("#btnSegundaEtapa").on('click',function () {
    console.log("Ooooi");
});
  • 1

    You have to use $(document).on('click','#btnSegundaEtapa', function () {. You’re using #btnSegundaEtapa more than once?

  • 1

    No, just this once

  • Okay, good! I linked a question that answers your question, basically what I put in the comment.

  • 1

    All right, my man, it worked out, thanks

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.