[英]Can't get input radio selected value
我陷入了復雜的html結構。 並且它也不能更改,因為它來自服務器端(外部)。
我正在嘗試獲取輸入單選的值。 但是不能。
遵循我嘗試過的方法但是,由於我功能不強大,所以無法解決。 而且也不知道我在想什么是對還是錯。
由於有多個元素我試圖與children
而也有我的HTML標記其他無線輸入。
console.log($('.ClearanceItem')[0].rows[0].cells[1].children[0].children[1].children[0].children[1].children.find('input[name="myRadio"]:checked').val());
<table> <tbody class="ClearanceItem"> <tr> <td> <table> <tbody> <tr> <td> <label> <input type="radio" checked="checked" value="1" name="Mobile">Clear </label> <label> <input type="radio" value="2" name="Mobile">Pending </label> <label> <input type="radio" value="3" name="Mobile">Waived Off </label> </td> </tr> </tbody> </table> </td> </tr> <tr> <td> <table> <tbody> <tr> <td> <label> <input type="radio" value="1" name="Computer">text1 </label> <label> <input type="radio" checked="checked" value="2" name="Computer">text2 </label> <label> <input type="radio" value="3" name="Computer">text3 </label> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table>
任何幫助將不勝感激。
$('input[name=radioName]:checked').val()
將返回選定的單選。
您還可以通過使用以下示例來指定無線電是其子窗體:
$('input[name=radioName]:checked', '#myForm').val()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.