onchange 이벤트 내에서 코드가 변경되는 데 문제가 있습니다.여러 데이터 센터에 잘못된 데이터가 표시되었습니다.
일부 코드는 작동하며 일부는 작동하지 않습니다.
<script>
$(document).on('change', '.sellkop', function() { // this is radio button
if ($("#rs").is(':checked')) {
$("#text_container").after(price_option());
};
if ($("#rk").is(':checked')) {
$("#price_container").remove();
$("#licensenumber_c").css({"display": 'none'
});
};
});
$('#category_group').on('change', function() { // this is select options
if ($(this).val() == 101) {
$("#underKategory").css({"display": 'none'});
$("#modelcontainer").remove();
$(".toolimage").css({ "display": 'block'});
$('.sellkop').on('change', function() { // this is radio button
if ($("#rs").is(':checked')) {
$("#licensenumber_c").css({"display": 'block'});
$(".toolimage").css({"display": 'block' });
} else {
$(".toolimage").css({"display": 'none'});
}
});
} else {
$(".bilar").remove();
$(".toolimage").css({ "display": 'none'});
}
if ($(this).val() == 102) {
$(".houses_container").remove();
$(".toolimage").css({"display": 'none'});
$("#underKategory").css({"display": 'inline-block'});
$("#modelcontainer").remove();
}
///............many other values continue
});
</script>
나는이 코드를 관리하고 그것을 단순화하는 더 좋은 방법이 있다는 것을 알고 있지만 어떻게 될지 모르겠다.
편집:
내가 원하는 것은 : 다음이 범주 옵션에서 너무마다 체크 버튼 내가 몇 가지를 얻을 필요가, 라디오 버튼 내가 옵션을 선택하면는 그 옵션에 값을 얻을 수있다 표시되거나 제거 된 데이터
여기에 내 문제가 보이는 fiddle입니다.
어떤 일이 발생합니까 : 내가 카테고리 -> 구매 확인 -> 다른 사람을 선택한 경우. 나는 ---> 스크립트 다음
업데이트 코드의 가독성 ...) –
왜 이벤트 핸들러 둥지 필요가 – max
이있다 http://stackoverflow.com/help/how-to-ask? 한 사건이 다른 사건에 의존 하는가? – adaam