1
我有這樣的HTML結構:的jQuery removeClass無法刪除時,JSON是空
<div class="row">
<div class="col-sm-6 p-l-0">
<div class="form-group form-group-default form-group-default-select2 required">
<select class="kurir">
<option select="selected"></option>
...
</select>
</div>
</div>
<div class="col-sm-6">
<div class="form-group form-group-default form-group-default-select2 required">
<select id="tarif" class="tarif full-width">
...
</select>
</div>
</div>
<div class="col-sm-12 notarif">
<p class="small hint-text no-margin text-danger hidden">
some text here.
</p>
</div>
</div>
,我有這個JavaScript:
$(".kurir").change(function() {
var _thiscache = $(this);
$.ajax({
url: json_url,
dataType: "JSON",
success: function(json){
if (json.length == 0) {
$(".tarif").prop("disabled", true);
$(".tarif").select2("val", "");
_thiscache.closest(".row").find(".notarif").$("p").removeClass("hidden");
}
}
...
爲什麼我不能p
當JSON刪除hidden
類給我空的結果?我在這裏錯過了什麼?感謝您的關注。
然後做'其他{_thiscache.closest( 「行 」)。找到(「 notarif 」)$(「 P」)。 remove(「hidden」);}' – guradio
'_thiscache.closest(「。row」)。find(「。notarif p.hidden」)。removeClass(「hidden」);' –
你認爲'find(「 .notarif「)。$(」p「)'是否有效?我不 –