JavaScript
Article

jQuery alert box yes or no

By 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');
}

Free Guide:

7 Habits of Successful CTOs

"What makes a great CTO?" Engineering skills? Business savvy? An innate tendency to channel a mythical creature (ahem, unicorn)? All of the above? Discover the top traits of the most successful CTOs in this free guide.

  • 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

Recommended
Sponsors
Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

Get the latest in JavaScript, once a week, for free.