Home  >  Article  >  Web Front-end  >  jquery SweetAlert plug-in implements responsive prompt box_javascript skills

jquery SweetAlert plug-in implements responsive prompt box_javascript skills

WBOY
WBOYOriginal
2016-05-16 15:44:331386browse

jquery pop-up layer plug-in supports message prompts, error prompts, confirmation box prompts, etc. The interactive experience is very good. Everyone uses WeChat Pay, Alipay, etc. to complete the user experience. This plug-in must support at least IE9. The usage method is also very simple and crude, which is in line with the popular jquery plug-in usage method.

Let me show you the effect first:

Online preview Source code download

The code is as follows:

<h1>Sweet Alert</h1>
<h2>A beautiful replacement for JavaScript's "Alert"</h2>
<button class="download">Download</button>
<h3>So... What does it do&#63;</h3>
<p>Here's a comparison of a standard error message. The first one uses the built-in <strong>alert</strong>-function, while the second is using <strong>sweetAlert</strong>.</p>
<div class="showcase normal">
<h4>Normal alert</h4>
<button>Show error message</button>
<h5>Code:</h5>
<pre class="brush:php;toolbar:false"><span class="attr">alert</span>(<span class="str">"Oops... Something went wrong!"</span>);
 

Sweet Alert

Code:
<span class="attr">sweetAlert</span>(<span class="str">"Oops..."</span>, <span class="str">"Something went wrong!"</span>, <span class="str">"error"</span>);

Pretty cool huh? SweetAlert automatically centers itself on the page and looks great no matter if you're using a desktop computer, mobile or tablet. It's even highly customizeable, as you can see below!

More examples

In these examples, we're using the shorthand function swal to call sweetAlert.

  • A basic message

    <span class="attr">swal</span>(<span class="str">"Here's a message!"</span>)
  • A title with a text under

    <span class="attr">swal</span>(<span class="str">"Here's a message!"</span>, <span class="str">"It's pretty, isn't it&#63;"</span>)
  • A success message!

    <span class="attr">swal</span>(<span class="str">"Good job!"</span>, <span class="str">"You clicked the button!"</span>, <span class="str">"success"</span>)
  • A warning message, with a function attached to the "Confirm"-button...

The above is a detailed explanation of how the jquery SweetAlert plug-in implements a responsive prompt box through code. I hope it will be helpful to you.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Implement magnifying glass effect based on jquery_jqueryNext article:Implement magnifying glass effect based on jquery_jquery

Related articles

See more