Jquery simulates alert's pop-up window plug-in _ jquery

Source: Internet
Author: User
This article mainly introduces information about the plug-in used to simulate alert using jquery. For more information, see the following demo address:

Http://runjs.cn/detail/miwszbne

Sharing instructions:

The Nth wheel was created, only for the simplest call. jquery simulates the pop-up window plug-ins of alert and confirm.

Call method:

$.alert('your message');$.alert('your message',function(){ $.alert('click ok button')});$.confirm('your message');$.confirm('your message',function(result){ if(result){  $.alert('click ok button') }else{  $.alert('click cancel button') }})

For ease of calling, the css style is directly written in js. In terms of compatibility, only IE8, chrome, and safari are tested.
IE8 is okay. Other modern browsers should also be OK.

(Function ($) {$. extend ({_ isalert: 0, alert: function () {if (arguments. length) {$. _ isalert = 1; $. confirm. apply ($, arguments) ;}}, confirm: function () {var args = arguments; if (args. length & (typeof args [0] = 'string ')&&! $ ('# Alert_overlay'). length) {if (! $ ('# Alert_style'). length) $ ('body'). append (''); Var dialog = $ ('

'+ Args [0] +'

OKCancel

'); If ($. _ isalert) dialog. find ('. alert_btn_cancel '). hide (); dialog. on ('textmenu', function () {return! 1 ;}). on ('click ','. alert_btn_ OK ', function () {dialog. remove (); if (typeof args [1] = 'function') args [1]. call ($ ,! 0 );}). on ('click ','. alert_btn_cancel ', function () {dialog. remove (); if (typeof args [1] = 'function') args [1]. call ($ ,! 1) ;}). appendTo ('body') ;}$. _ isalert = 0 ;}}) ;}( $ );

The above is all the content of this article. I hope you will like it.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.