<input type="radio" name="haspayperiod" id="haspayperiod_1" value="0" checked onclick="annualtype_change(this.value);" <?= ($fundcode!="F02001") ? "style='display:none;'" : "" ?> />


像上面一样,在默认阶段,我使用了checked和onclick来调用annualtype_change(this.value)

我的annualtype_change函数如下所示。

function annualtype_change(year) {
            $('#regular_TN').hide();
            $('#regular_TN_1').show();

            if (year == "1") {
                $('#regular_TN_1').hide();
                $('#regular_TN_2').show();

            } else {
                $('#regular_TN_1').show();
                $('#regular_TN_2').hide(); //default
            }


        }


但是,尽管它显示为复选框,但默认情况下不显示regular_TN_1

    <td id="regular_TN_1" >
      <span class="fixprice" name="price" id="price_1"value=20,000>20,000</span>dollar
   </td>
    <td id="regular_TN_2" style="display:none" >
      <span class="fixprice" name="price" id="price_2" value=10,000>10,000</span>dollar
   </td>


我应该如何使用checkedonclick正常工作。

最佳答案

该问题与标签名称和标签ID有关,修复代码时应仔细进行调整。

关于javascript - onclick和选中的使用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32115098/

10-11 12:59
查看更多