我试图做一个字符串比较像这样在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);' –
请为你的破解代码提供一个例子。 –