0

我有这个 HTML:

<div id="broker_referral_block" style="display: none;">
    <label for="">* How did your broker/agent introduce you to the project?</label><br>
    <input type="radio" name="referral2" value="Site Visit" class="referral2"> Site Visit
    <br>
    <input type="radio" name="referral2" value="Conversation through social media" class="referral2"> Conversation through social media
    <br>
    <input type="radio" name="referral2" value="Referrals" class="referral2"> Referrals
    <br>
    <input type="radio" name="referral2" value="Phone Calls" class="referral2"> Phone Calls
    <br>
    <input type="radio" name="referral2" value="Developer" class="referral2"> Developer
    <br>
    <input type="radio" name="referral2" value="Other" class="referral2"> Other
</div>

我不知道为什么当我尝试 serializeArray 时它不包括在内,我var test = jQuery(this).serializeArray();没有发现任何问题。我知道这display:none;不是问题,因为这个领域:

<div id="broker_referral_block_other_field" style="display: none;">
    <input type="text" class="form-control referral2other" name="referral2other" id="referral2other">
</div>

被读取,只是没有价值(这是我想要的)。我也不明白为什么要读取此块中的所有内容:

<div id="existing_loans_block" style="display: none;">
    <label for="">* Loan</label>
    <input type="text" class="form-control existing_loans_detail" name="loan" id="loan">
    <label for="">* Amount</label>
    <input type="text" class="form-control existing_loans_detail" name="loan_amount" id="loan_amount">
    <label for="">* Monthly Amoritization</label>
    <input type="text" class="form-control existing_loans_detail" name="loan_amort" id="loan_amort">
    <label for="">* Term</label>
    <input type="text" class="form-control existing_loans_detail" name="loan_term" id="loan_term">
    <label for="">* Status</label>
    <!-- This bit does not get included too -->
    <select name="loan_status" id="loan_status" class="form-control existing_loans_detail">
        <option value="" selected disabled hidden>Select loan status...</option>
        <option value="Active">Active</option>
        <option value="Updated">Updated</option>
    </select>
</div>

除了loan_status. 所有这些都正确包装在表单标签中。这是我的jQuery:

jQuery("#hbcq_form").submit(function(e){
    e.preventDefault();
    var test = jQuery(this).serializeArray();
...

我做了一个console.log(test),那是我发现它referral2loan_status没有被包含在序列化中的时候。我还仔细检查过,这些没有名称冲突。

4

1 回答 1

1

jQuery 序列化隐藏(显示:无)表单元素不起作用。解决方法?

看看这个你可以找到帮助完整的答案

于 2020-07-11T06:33:36.507 回答