###前提・実現したいこと
クリックした際に条件分岐のスクリプトを動かしたいです。
アラートで税を表示させるスクリプトです。
###発生している問題・エラーメッセージ
###該当のソースコード
javaScript
1<!DOCTYPE html> 2<html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Varinus</title> 6 <script type="text/javascript"> 7 8 function tax() { 9 var prefCode = "神奈川" ; 10 11 if (prefCode == "長野") { 12 taxPrecentage = 9.5; 13 } else if (prefCode == "和歌山") { 14 taxPrecentage = 6.5 ; 15 } else if (prefCode == "神奈川") { 16 taxPrecentage 17 } else if (prefCode == "兵庫") { 18 taxPrecentage = 2.0 ; 19 } 20 21 alert (taxPrecentage); 22 } 23 24 </script> 25 </head> 26 <body> 27 <p onclick="tax()"> 28 test 29 </p> 30 </body> 31</html> 32
###試したこと
宣言やイベントハンドラの見直しを行いました
###補足情報(言語/FW/ツール等のバージョンなど)
回答2件
あなたの回答
tips
プレビュー