我有问题,当我第一次改变select的值时,它的工作效果不错,但是当第二次更改值时,代码不起作用!
这是我的代码:
$(function($) {
$('.sf-field-post-meta-typeofmeal .sf-input-select').change(function () {
if($(this).val()=="breakfast")
{
$('.sf-field-post-meta-breakfast').show();
}
else
{
$('.sf-field-post-meta-breakfast').hide();
}
});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form data-sf-form-id="3146" data-is-rtl="1" data-maintain-state="1" data-results-url="http://kalem.sa/client/msa3d_r/?sfid=3146" data-ajax-url="http://kalem.sa/client/msa3d_r/?sfid=3146&sf_data=all" data-ajax-form-url="http://kalem.sa/client/msa3d_r/?sfid=3146&sf_action=get_data&sf_data=form" data-display-result-method="archive" data-use-history-api="1" data-template-loaded="0" data-lang-code="" data-ajax="1" data-ajax-data-type="html" data-ajax-target="#posts-container" data-ajax-pagination-type="normal" data-ajax-links-selector=".pagination a" data-update-ajax-url="1" data-scroll-to-pos="custom" data-custom-scroll-to="#posts-container" data-scroll-on-action="all" data-init-paged="1" data-auto-update="1" data-auto-count="1" data-auto-count-refresh-mode="1" action="http://kalem.sa/client/msa3d_r/?sfid=3146" method="post" class="searchandfilter" id="search-filter-form-3146" autocomplete="off" data-instance-count="1">
<ul>
<li class="sf-field-post-meta-typeofmeal" data-sf-field-name="_sfm_typeofmeal" data-sf-field-type="post_meta" data-sf-field-input-type="select" data-sf-meta-type="choice">
<h4 data-fontsize="13" data-lineheight="19">النوع</h4>
<label>
<span class="screen-reader-text">اختر الخيار</span>
<select name="_sfm_typeofmeal[]" class="sf-input-select" title="اختر الخيار">
<option class="sf-level-0 sf-item-0 sf-option-active" selected="selected" data-sf-depth="0" value="">الجميع</option>
<option class="sf-level-0 " data-sf-count="1" data-sf-depth="0" value="breakfast">فطور</option>
<option class="sf-level-0 " data-sf-count="1" data-sf-depth="0" value="candy">حلويات</option>
</select>
</label>
</li>
<li class="sf-field-post-meta-breakfast" data-sf-field-name="_sfm_breakfast" data-sf-field-type="post_meta" data-sf-field-input-type="select" data-sf-meta-type="choice">
<h4 data-fontsize="13" data-lineheight="19">الفطور</h4>
<label>
<span class="screen-reader-text">اختر الخيار</span>
<select name="_sfm_breakfast[]" class="sf-input-select" title="اختر الخيار">
<option class="sf-level-0 sf-item-0 sf-option-active" selected="selected" data-sf-depth="0" value="">الجميع</option>
<option class="sf-level-0 " data-sf-count="0" data-sf-depth="0" value="ارميني">ارميني</option>
<option class="sf-level-0 " data-sf-count="0" data-sf-depth="0" value="بانكيك">بانكيك</option>
<option class="sf-level-0 " data-sf-count="0" data-sf-depth="0" value="بوفيّة">بوفيّة</option>
</select>
</label>
</li>
</ul>
</form>