前提
ここに質問の内容を詳しく書いてください。
(例)
WordpressのElementorにて、MWformでお問い合わせフォームを作っています。
その中でdatepicker のカレンダーで土曜日や平日(日曜日は)非表示にしています。を選ぶとカレンダー下の「ご希望の時間帯からお選びください」欄から一部の時間帯しか選べないようにしたいです。
jqueryでそのコードを書きたいです。
https://nayabashi-kick.com//form-test/
https://nayabashi-kick.com//form-test/
実現したいこと
-カレンダーの日にちをクリックしたら曜日を取得し曜日に応じて、optionタグの一部を選べないようにする
jQuery
1<script> 2//日曜日を選択不可 3 jQuery(function(){ jQuery('#datepicker').datepicker(); jQuery('#datepicker').datepicker('option','beforeShowDay',function(date){ var ret = [(date.getDay() != 0 && date.getDay() != 7)]; return ret; });}); 4 5 // jQuery(function() { 6 7 // jQuery('#datepicker').datepicker(); jQuery('#datepicker').datepicker('option','beforeShowDay',function(date){ var ret = [(date.getDay() != 6 && date.getDay() != 7)]; return ['true', 'yasumi']; }); 8 9 10// jQuery('#Date').datepicker({ 11// beforeShowDay: function(date) { 12// if (date.getDay() == 6) { 13// // クラス名を設定 14// return [true, 'class-store-closed', '']; 15// jQuery('option').hide(); 16// jQuery('select').addClass('saturdey'); 17 18// } 19// } 20// }); 21 22 // }); 23 24 25 26</script>
MWformの入力テキスト
1お名前 2 3[mwform_text name="name" placeholder="name"] 4 5ふりがな 6 7[mwform_text name="name_kana" placeholder="ふりがな"] 8 9電話番号 10 11[mwform_text name="tel" placeholder="電話番号"] 12 13メールアドレス 14 15[mwform_text name="email"] 16 17メールアドレス確認 18 19[mwform_text name="email_check" ] 20 21郵便番号 22 23[mwform_text name="pcode"] 24 25ご住所 26 27[mwform_text name="adress"] 28 29お問い合わせ内容 30 31[mwform_radio name="select_form" id="select_form" class="select_form" children="お問合せ,体験希望" value="お問合せ"] 32 33体験したい店舗を選択してください 34 35[mwform_radio name="select_shop" id="select_shop" class="select_shop" children="納屋橋キック1号店" value=""] 36 37希望日時 38※体験の対応時間は下記の時間内でご入力下さい。 39平日 18:00~22:00 40土曜 15:00~18:00 41祝日 15:00~20:00 42日曜日は定休日となります。 43 44[mwform_datepicker name="days" id="datepicker" size="30" placeholder="ご希望の日にちを選択してください"] 45[mwform_select name="dateserect" id="希望日時" children="ご希望のお時間帯を選択してください,15:00~16:00,16:00~17:00,17:00~18:00,18:00~19:00,19:00~20:00,20:00~21:00,21:00~22:00" value=""] 46 47お問合せ詳細 48 49[mwform_textarea name="contents"] 50[mwform_backButton value="戻る"] 51[mwform_submitButton name="submit" confirm_value="確認する" submit_value="送信する "] 52
試したこと
// jQuery(function() { // jQuery('#datepicker').datepicker(); jQuery('#datepicker').datepicker('option','beforeShowDay',function(date){ var ret = [(date.getDay() != 6 && date.getDay() != 7)]; return ['true', 'yasumi']; });
// jQuery('#Date').datepicker({
// beforeShowDay: function(date) {
// if (date.getDay() == 6) {
// // クラス名を設定
// return [true, 'class-store-closed', ''];
// jQuery('option').hide();
// jQuery('select').addClass('saturdey');
// }
// }
// });
// });
などを試して、曜日を選ぶとselectタグなどにクラス名を付与させ、クラス名が付与されている場合にoptionタグの一部をdisplay:noneなどで非表示にしようと思いましたがそもそもクラス名がselectタグやoptionタグに付与されません。付与されるのはカレンダー画面のセルになってしまいます。
お願いします、助けてください。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。