我有以下jQuery在POST
(function($) {
$( document ).ready(function() {
jQuery('#post').submit(function() {
if ($("#_sku").val() == '') {
alert("Please enter a valid GTIN");
$('#ajax-loading').hide();
$('#publish').removeClass('button-primary-disabled');
$('#_sku').focus();
return false;
}
return true;
});
});
}(jQuery));
这当前效果很好,但是我需要为if statement
添加另一个条件。我只需要在以下选择框的值为eqaul为“simple”
<select id="product-type" name="product-type">
<optgroup label="Product Type">
<option value="simple" selected='selected'>Simple product</option>
<option value="grouped" >Grouped product</option>
</optgroup>
</select>
我在if语句中试过这个:
if ($("#_sku").val() == '' && $("#_product-type").val() == 'simple') {
但是当product-type等于“simple”时,这不适用于if语句中的规则。任何人都可以在这里提出问题的建议吗?
答案 0 :(得分:2)
这对你有用。您也可以使用===而不是==这更快更准确。因为===不进行任何演员
return [
'class' => 'yii\db\Connection',
'dsn' => 'sqlite:somedb',
'charset' => 'utf8',