我有这个,所以当页面加载获取值时,如果为 true,则显示一个有效的 msg,但是当我使用更改时,更改没有,所以我使用实时更改功能,当你更改时有效,但现在默认的负载检查没有?有什么想法吗?
$(document).ready(function() {
var target = $('.product-options select').find(":selected").val();
if(target == "2" || target == "4"){
$(".beans-msg").html("would you like beans?").show();
} else {
$(".beans-msg").hide();
}
console.log(target);
$('.product-options select').live('change',function(){
var changedVal = $(this).find(":selected").val();
if(changedVal == "2" || changedVal == "4"){
$(".beans-msg").html("would you like beans?").show();
} else {
$(".beans-msg").hide();
}
console.log(changedVal);
});
});