>  기사  >  웹 프론트엔드  >  jquery 플러그인 jquery.confirm이 확인 메시지를 팝업합니다 message_javascript 기술

jquery 플러그인 jquery.confirm이 확인 메시지를 팝업합니다 message_javascript 기술

WBOY
WBOY원래의
2016-05-16 15:24:151604검색

본 글에서는 jquery.confirm 팝업 확인 메시지 구현 방법을 소개하고 있으며, 참고용으로 특별히 공유드립니다.

실현 효과:

특정 코드:

1. 플러그인 기본 매개변수

// 默认参数
$.confirm.defaults = {
 // 样式
 css: "http://static.qianduanblog.com/css/jquery.confirm/default.min.css?v=" + Math.ceil(new Date() / 86400000),
 // 确认框内容
 content: "确认吗?",
 // 确认按钮文字
 sureButton: "确认",
 // 取消按钮文字
 cancelButton: "取消",
 // 位置
 position: {},
 // 自动打开
 autoOpen: false,
 // 动画持续时间
 duration: 123,
 // 打开确认框回调
 onopen: emptyFn,
 // 单击了确认或者取消回调
 onclick: emptyFn,
 // 确认回调
 onsure: emptyFn,
 // 取消回调
 oncancel: emptyFn,
 // 关闭确认框回调
 onclose: emptyFn
}

2. 플러그인 구조 및 스타일
jquery.confirm의 dom 구조는 다음과 같습니다.

<div class="jquery_confirm____" style="display:none">
 <div class="jquery_confirm____body">确认框消息</div>
 <div class="jquery_confirm____footer">
  <button class="button button-primary jquery_confirm____sure">确认</button>
  <button class="button button-error jquery_confirm____cancel">取消</button>
 </div>
</div>

기본 플러그인 스타일은 css.3을 기반으로 합니다. 기본 플러그인 스타일 주소는 한 번만 렌더링되며 처음 스타일은 여러 번 렌더링되지 않습니다. 플러그인을 사용하는 것이 우선합니다.

3.사용방법

// 打开确认框
$.confirm({
 content: "确认要查看吗?",
 onopen: function() {
  alert("确认框打开了!");
 },
 onclose: function() {
  alert("确认框关闭了!");
 },
 onsure: function() {
  alert("你单击了确认按钮!");
 },
 oncancel: function() {
  alert("你单击了取消按钮!");
 },
 onclick: function(s) {
  if (s) {
   alert("你单击了确认按钮!");
  } else {
   alert("你单击了取消按钮!");
  }
 }
});
 
$.confirm("确认吗?", function(s) {
 if (s) {
  alert("你单击了确认按钮!");
 } else {
  alert("你单击了取消按钮!");
 }
});

이 기사가 jquery 프로그래밍을 배우는 모든 사람에게 도움이 되기를 바랍니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.