Jquery 获取select 自定义标签数据

    xiaoxiao2022-07-02  102

    Jquery 获取select 自定义标签数据

    html

    <select id="methodSelect" name="method"> [#list orderPayments as orderPayment] <option value="${orderPayment.paymentMethod}" data-amount="${orderPayment.amount}">${orderPayment.paymentMethod}<\/option> <option value="${orderPayment.paymentMethod}" data-amount="${orderPayment.amount}">${orderPayment.paymentMethod}<\/option> <option value="${orderPayment.paymentMethod}" data-amount="${orderPayment.amount}">${orderPayment.paymentMethod}<\/option> [/#list] <\/select>

    js

    $("body").on("change", "#methodSelect", function () { alert($(this).find("option:selected").data("amount")); })
    最新回复(0)