Wait online, urgent, how to judge the linkage problem of select

how does js implement when the first select selects 2, the first optionvalue of the second select becomes 2, automatically Filter disables value=1 "s option?
online, etc., urgent

< hr >
    <select id="s1" onchange="bb()">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
    </select>

    <select id="s2">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
    </select>

    <script type="text/javascript">

        var s1Val=$("-sharps1 option:selected");
        var s2Val=$("-sharps2 option:selected");

        function bb(){
            console.log(s1Val.val());
        }

    </script>
Apr.01,2021

use the change event to get the subscript of the first $("- sharps1 option:selected"), then subtract 1 from this subscript, and delete the corresponding option of the second drop-down menu


.
<select id="s1" onchange="bb(this)">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
</select>

<select id="s2">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
</select>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
    function bb(_this) {
        //$("-sharps2 option[value='" + $(_this).val() + "']").attr("selected", "selected");
        $("-sharps2").children("option").each(function () {
            var temp_value = $(this).val();
            if (temp_value <= $(_this).val()) {
                $(this).attr("disabled", "disabled");
            }
        });
    }
</script>

I don't know if it's what the landlord wants.

I think so. I guess!

<script type="text/javascript">
    function bb(_this) {
        $("-sharps2 option[value='" + $(_this).val() + "']").attr("selected", "selected");
        $("-sharps2").children("option").each(function () {
            var temp_value = $(this).val();
            if (temp_value < $(_this).val()) {
                $(this).hide();
            } else {
                $(this).show();
            }
        });
    }
</script>

var s1Value $("- sharps1 option:selected") val ();
var s2Va = s1Val==2? $('- sharps2'). Val (2): $('- sharps2'). Val ($("- sharps2 option:selected") val ())

)
Menu