jQuery alert box yes or no

Sam Deering

There are a few options for capturing events for alert and dialog boxes in jQuery including plugins and dialog boxes. Also jQuery UI offers us some options for custom dialogs. This page also offers a few good different types of modal windows.

Also you might consider using plain JavaScript you might do something like this, quick and easy!

var answer = confirm('Are you sure you want to delete this?');
if (answer)
{
  console.log('yes');
}
else
{
  console.log('cancel');
}

Win an Annual Membership to Learnable,

SitePoint's Learning Platform

  • http://www.facebook.com/profile.php?id=660928137 Rami Kellesly

    Thank you Sam it’s very helpful ,Is there is a way to change the alert button text other than “ok” “cancel”?

  • http://www.facebook.com/nguyentrunghieu.hh Hiếu Nguyễn

    thank verry much

  • Ayesh

    Thanks!!

  • Sijo Thomas

    good one..thanks