どうぞ... jQuery 1.8.3 を使用して...
実験 1 :ライブ デモ
コード
<select name="query" id="query">
<option value="join-us">Join Us</option>
<option value="work-with-us">Work with us</option>
<option value="about-pf">About Planet Fitness</option>
<option value="other">Other</option>
</select>
<script>
var query1 = $('#query option:selected').text();
var query2 = $('#query').val();
var query3 = $('#query').text();
alert('query1 = ' + query1 + '\nquery2 = ' + query2 + '\nquery3 = ' + query3);
console.log('query1 = ' + query1 + '\nquery2 = ' + query2 + '\nquery3 = ' + query3);
</script>
出力
クロム:
query1 = Join Us
query2 = join-us
query3 =
Join Us
Work with us
About Planet Fitness
Other
いいえ:
query1 = Join Us
query2 = join-us
query3 = Join Us Work with us About Planet Fitness Other
ファイアフォックス:
query1 = Join Us
query2 = join-us
query3 =
Join Us
Work with us
About Planet Fitness
Other
実験 2 :ライブ デモ
コード
<script>
function getMyValue() {
var query1 = $('#query option:selected').text();
var query2 = $('#query').val();
var query3 = $('#query').text();
alert('query1 = ' + query1 + '\nquery2 = ' + query2 + '\nquery3 = ' + query3);
console.log('query1 = ' + query1 + '\nquery2 = ' + query2 + '\nquery3 = ' + query3);
}
</script>
</head>
<body>
<select name="query" id="query">
<option value="join-us">Join Us</option>
<option value="work-with-us">Work with us</option>
<option value="about-pf">About Planet Fitness</option>
<option value="other">Other</option>
</select>
<button onclick="getMyValue();">Click Me</button>
</body>
出力(「Work with us」を選択してボタンをクリック)
クロム:
query1 = Work with us
query2 = work-with-us
query3 =
Join Us
Work with us
About Planet Fitness
Other
いいえ:
query1 = Work with us
query2 = work-with-us
query3 = Join Us Work with us About Planet Fitness Other
ファイアフォックス:
query1 = Work with us
query2 = work-with-us
query3 =
Join Us
Work with us
About Planet Fitness
Other
推論
コードは正常に動作します。呼び出し方法に問題があるはずです。アラートをあちこちに配置してみてください...