// // jQueryプラグイン toggle // エリア表示切り替えプラグイン // flg 0 : 非表示、1 : 表示 // (function($) { $.fn.toggle = function (button, flg) { var toggle = function(elm, flg) { if (flg == 1) { $(button).find('span.mark').html('▼'); $(elm).css('display', 'block'); } else { $(button).find('span.mark').html('▶︎'); $(elm).css('display', 'none'); } $(elm).data('toggle_flg', flg); }; if(flg == undefined) flg = 1; return $(this).each(function(){ var elm = $(this); toggle(elm, flg); button.on('click', function() { var flg = $(elm).data('toggle_flg'); if (flg == undefined || flg == 0) { flg = 1; } else { flg = 0; } toggle(elm, flg); $(elm).data('toggle_flg', flg); }); }); }; }(jQuery));