简体   繁体   中英

Alertify for OnClick Event of Button

I'm trying to display a message that the user has clicked Delete button when he/she clicks on it. This is what I'm doing:

<script>
    $('#button_del').on('click',function(e){
        alertify.error('You have clicked on Delete!');
    });
</script>

But no message appears when I click on the button. What am I doing wrong?

There are only four possibilities here:

  1. You don't load your libraries correctly: jQuery and alertify.
  2. There is no element with the button_del ID, or there are markup errors involving it.
  3. You're not actually clicking #button_del .

4. the most likely one :

You need to attach the click handler when the document is loaded, otherwise #button_del is probably not available/loaded yet!

$(document).ready(function() {
    $('#button_del').on('click',function(e){
        alertify.error('You have clicked on Delete!');
    });
});

Even if the first three conditions are met, you'd still have to change this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM