1

我有以下代码

 var cval2 = $(':input[value^="ltrXYAxis"]:checked').map(function () {
                return this.value.replace('ltrXYAxis', '');
            }).get().join('@@');

它返回检查项目两次

喜欢

第一项@@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>

我的查询有什么问题

4

1 回答 1

1

使用类似下面的东西

 var cval2 = $(':#ltrXYAxis option:selected:not(:disabled)').map(function () {
                return this.value.replace('ltrXYAxis', '');
            }).get().join('@@');
于 2013-10-01T12:21:07.150 回答