我試圖做一個字符串比較像這樣在JQuery中jQuery的比較字符串輸入值
$('#select_directory_type').on('change', function() {
window.alert($(this).val()); // I can see the selection is "SOMETHING"
if("SOMETHING" === $(this).val()){
// Never gets executed even when the selection is "SOMETHING".
} });
另一個問題是,什麼是
$this.val()
and
$(this).val()
感謝的區別!
這是一個可搜索的問題和答案索引。請一次提出一個問題。 –
'$ this'未定義。如果你在談論DOM語法,你需要'this.value',否則你需要明確定義'var $ this = $(this);' –
請爲你的破解代碼提供一個例子。 –