简体   繁体   中英

Radio button not checked when again loading form with ajax

I have an element which I use for upadting values in the database.

<p id="valuta">
  <label for="valuta">Valuta:</label><br/>
  <select id="valuta2" name="valuta2">
    <option value="USD">US </option>
    <option value="EUR">EUR </option>
    <option value="RSD">RSD </option>
  </select></br>
  Konvertuj cenu?</br>
  <input type="radio" id='conversion' class='conversion' name="conversion" checked="checked" value="1">DA<br>
  <input type="radio" class="conversion" name="conversion" value="2">NE
</p></br>

But when I try to load this element my radio button isnt checked. I am doing operation with ajax.

This is what I try after ajax operation in the success part:

 $('#conversion').prop('checked');
 $('#conversion').attr('checked');
 $('#conversion').attr('checked','checked')

no result? Any idea?

.prop('checked', ...)可以为truefalse ,因此正确的代码为:

$('#conversion').prop('checked', true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM