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.