我有以下代码
var cval2 = $(':input[value^="ltrXYAxis"]:checked').map(function () {
return this.value.replace('ltrXYAxis', '');
}).get().join('@@');
它返回两次检查项目
像
@@与firstItem @@ seconditem @@与firstItem seconditem
我希望输出像他的
@@与firstItem @@ seconditem
相关HTML
<ul class="ui-multiselect-checkboxes ui-helper-reset" style="height: 175px;">
<li class="">
<label class="ui-corner-all ui-state-hover" for="ui-multiselect-lsltrXYAxis-option-0" title="">
<input id="ui-multiselect-lsltrXYAxis-option-0" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisApple Identifier">
<span>AppleIdentifier</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-1" title="">
<input id="ui-multiselect-lsltrXYAxis-option-1" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisCustomer Price">
<span>Customer Price</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-2" title="">
<input id="ui-multiselect-lsltrXYAxis-option-2" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisDeveloper Proceeds">
<span>Developer Proceeds</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-3" title="">
<input id="ui-multiselect-lsltrXYAxis-option-3" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisParent Identifier">
<span>Parent Identifier</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-4" title="">
<input id="ui-multiselect-lsltrXYAxis-option-4" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisProduct Type Identifier"><span>Product Type
Identifier</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-5" title="">
<input id="ui-multiselect-lsltrXYAxis-option-5" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisRevenue">
<span>Revenue</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-6" title="">
<input id="ui-multiselect-lsltrXYAxis-option-6" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisSKU">
<span>SKU</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-7" title="">
<input id="ui-multiselect-lsltrXYAxis-option-7" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisTotal Revenue in Local Currency">
<span>Total Revenue in Local Currency</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-8" title="">
<input id="ui-multiselect-lsltrXYAxis-option-8" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisUnits Downloaded">
<span>Units Downloaded</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-9" title="">
<input id="ui-multiselect-lsltrXYAxis-option-9" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisUnits Sold">
<span>Units Sold</span>
</label>
</li>
<li class="">
<label class="ui-corner-all" for="ui-multiselect-lsltrXYAxis-option-10" title="">
<input id="ui-multiselect-lsltrXYAxis-option-10" name="multiselect_lsltrXYAxis" title="" type="checkbox" value="ltrXYAxisVersion">
<span>Version</span>
</label>
</li>
</ul>
我的查询错误
答案 0 :(得分:1)
使用下面的内容
var cval2 = $(':#ltrXYAxis option:selected:not(:disabled)').map(function () {
return this.value.replace('ltrXYAxis', '');
}).get().join('@@');