{"id":6186,"date":"2024-07-30T11:53:38","date_gmt":"2024-07-30T02:53:38","guid":{"rendered":"https:\/\/taitan916.info\/blog\/?p=6186"},"modified":"2024-05-18T12:04:10","modified_gmt":"2024-05-18T03:04:10","slug":"post-6186","status":"publish","type":"post","link":"https:\/\/taitan916.info\/blog\/archives\/6186","title":{"rendered":"JavaScript\u306e\u30ea\u30c3\u30c1\u306aalert \/ confirm\u307d\u3044\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u8868\u793a\u3059\u308b\u300csweetalert2\u300d\u306e\u5229\u7528\u65b9\u6cd5"},"content":{"rendered":"<p>JavaScript\u306ealert \/ confirm\u306f\u30d6\u30e9\u30a6\u30b6\u306b\u3088\u3063\u3066\u8868\u793a\u4f4d\u7f6e\u3084\u30c7\u30b6\u30a4\u30f3\u304c\u7570\u306a\u308b\u3002\u307e\u305f\u3001\u305d\u3082\u305d\u3082\u306e\u898b\u305f\u76ee(\u30c7\u30b6\u30a4\u30f3)\u3082\u5c11\u3005\u6c17\u306b\u306a\u308b\u3068\u3053\u308d\u3002\u3053\u306e\u8fba\u308a\u3092\u89e3\u6c7a\u3067\u304d\u306a\u3044\u304b\u8abf\u3079\u305f\u3068\u3053\u308d\u300csweetalert2\u300d\u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u5bfe\u5fdc\u3067\u304d\u305d\u3046\u3002\u4ee5\u4e0b\u306b\u5229\u7528\u65b9\u6cd5\u3092\u30e1\u30e2\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>sweetalert2<\/h2>\n<h3>\u516c\u5f0f\u30b5\u30a4\u30c8<\/h3>\n<p><a href=\"https:\/\/sweetalert2.github.io\/\" target=\"_blank\" rel=\"noopener\">https:\/\/sweetalert2.github.io\/<\/a><\/p>\n<h3>\u30c7\u30e2\u30da\u30fc\u30b8<\/h3>\n<p><a href=\"https:\/\/sweetalert2.github.io\/#examples\" target=\"_blank\" rel=\"noopener\">https:\/\/sweetalert2.github.io\/#examples<\/a><\/p>\n<h3>CDN<\/h3>\n<p>CDN\u3067\u4f7f\u3046\u5834\u5408\u306f\u4ee5\u4e0b\u3092\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/sweetalert2@11.11.0\/dist\/sweetalert2.all.min.js\"&gt;&lt;\/script&gt;\r\n&lt;link href=\"https:\/\/cdn.jsdelivr.net\/npm\/sweetalert2@11.11.0\/dist\/sweetalert2.min.css\" rel=\"stylesheet\"&gt;<\/pre>\n<p>&nbsp;<\/p>\n<h2>\u30b5\u30f3\u30d7\u30eb<\/h2>\n<p><a href=\"https:\/\/taitan916.info\/sample\/sweetalert2\/\" target=\"_blank\" rel=\"noopener\">https:\/\/taitan916.info\/sample\/sweetalert2\/<\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>\u5229\u7528\u65b9\u6cd5<\/h2>\n<h3>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;button id=\"alert\" type=\"button\" class=\"button-class\"&gt;alert&lt;\/button&gt;\r\n&lt;button id=\"confirm\" type=\"button\" class=\"button-class\"&gt;confirm&lt;\/button&gt;\r\n\r\n&lt;script src=\"https:\/\/cdn.jsdelivr.net\/npm\/sweetalert2@11.11.0\/dist\/sweetalert2.all.min.js\"&gt;&lt;\/script&gt;\r\n&lt;link href=\"https:\/\/cdn.jsdelivr.net\/npm\/sweetalert2@11.11.0\/dist\/sweetalert2.min.css\" rel=\"stylesheet\"&gt;\r\n&lt;script&gt;\r\ndocument.getElementById(`alert`).onclick = function() {\r\n    Swal.fire(`alert\u30c6\u30b9\u30c8`);\r\n}\r\n\r\ndocument.getElementById(`confirm`).onclick = function() {\r\n    Swal.fire({\r\n        title: `confirm\u30c6\u30b9\u30c8`,\r\n        showDenyButton: true,\r\n        confirmButtonText: `Yes`,\r\n        denyButtonText: `No`\r\n    }).then((result) =&gt; {\r\n        if( result.isConfirmed ){\r\n            Swal.fire(`Yes\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3057\u305f\u3002`);\r\n        }else if (result.isDenied){\r\n            Swal.fire(`No\u3092\u30af\u30ea\u30c3\u30af\u3057\u307e\u3057\u305f\u3002`);\r\n        }\r\n    });\r\n}\r\n&lt;\/script&gt;<\/pre>\n<h3>\u89e3\u8aac\u7b49<\/h3>\n<p>\u30d0\u30cb\u30e9JS\u5bfe\u5fdc\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u305f\u3081\u300cdocument.getElementById\u300d\u3068\u3057\u3066\u3044\u308b\u304c\u3001\u3082\u3061\u308d\u3093jQuery\u3092\u5c0e\u5165\u3057\u3066\u300c$(`#alert`).on('click',~~)\u300d\u3068\u3044\u3046\u5f62\u3067\u3082\u554f\u984c\u7121\u3057\u3002<\/p>\n<p>\u307e\u305f\u3001\u5404\u7a2e\u30d1\u30e9\u30e1\u30fc\u30bf\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/sweetalert2.github.io\/#configuration\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089\u306e\u30da\u30fc\u30b8<\/a>\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JavaScript\u306ealert \/ confirm\u306f\u30d6\u30e9\u30a6\u30b6\u306b\u3088\u3063\u3066\u8868\u793a\u4f4d\u7f6e\u3084 ... <\/p>\n","protected":false},"author":1,"featured_media":1067,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[100],"class_list":["post-6186","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-library"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/6186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/comments?post=6186"}],"version-history":[{"count":3,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/6186\/revisions"}],"predecessor-version":[{"id":6479,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/posts\/6186\/revisions\/6479"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media\/1067"}],"wp:attachment":[{"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/media?parent=6186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/categories?post=6186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/taitan916.info\/blog\/wp-json\/wp\/v2\/tags?post=6186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}