我想按照选择顺序在div中显示选中的选项
1. What is the biggest skin concern in India in your practice?
Number in order of priority
[] Acne
[] Dark circles under eyes
[] Dry skin div is here and it will show list as per selection order
[] Oily skin
[] Skin color
[] Skin tone evenness
[] Wrinkles
如果有人选择深色皮肤然后痤疮我的div应该首先列出深色皮肤,然后痤疮应该来了
input type="checkbox" name="skin_concern[]" id="a2" title="sc" value="Dark circles under eyes" class="validate[required] radio"
请提供解决方案,以便我按照jquery中的选择顺序显示此选项。
提前致谢
答案 0 :(得分:0)
试试这段代码,如果这不符合您的要求,请告诉我......
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<style type="text/css">
.show_div{
float: left;
width: 200px;
height: 200px;
background: lightyellow;
border: 1px solid #ccc;
}
</style>
<input type="checkbox" class="haircls" name="skin_concern[]" value="Acne" /> Acne<br />
<input type="checkbox" class="haircls" name="skin_concern[]" value="Dark circles under eyes" /> Dark circles under eyes<br />
<input type="checkbox" class="haircls" name="skin_concern[]" value="Dry skin" /> Dry skin<br />
<input type="checkbox" class="haircls" name="skin_concern[]" value="Oily skin" /> Oily skin<br />
<input type="checkbox" class="haircls" name="skin_concern[]" value="Skin color" /> Skin color<br />
<input type="checkbox" class="haircls" name="skin_concern[]" value="Skin tone evenness" /> Skin tone evenness<br />
<script type="text/javascript">
$('.haircls').change(function(){
if($(this).is(':checked')){
document.getElementById('show_div_ID').innerHTML += '<span style="float:left;width:100%;">'+ this.value +'</span>';
} else {
$("#show_div_ID span:contains('"+this.value+"')").remove();
}
});
</script>
<div class="show_div" id="show_div_ID"></div>