在.mSubIndex更改为1时,我想禁用下一个选择框。以下代码无效。我在解决选择元素时遇到问题 - 不确定它是否与表格中的任何内容有关
echo "<form action='menu-add.php' method='post'>";
echo "<tr>";
echo "<td><input name='mIndex' value=''></td>";
echo "<td><input name='mSubIndex' class='mSubIndex' value=''></td>";
echo "<td><input name='mTitle' value=''></td>";
echo "<td class='pag'>";
echo "<select name='pageName' class='pageName'>";
echo "<option value='0'>Please Choose Page</option>";
foreach (glob('../*.php') as $pageFile) {
$pageFile = substr($pageFile, 3);
echo "<option value='".$pageFile."'>".$pageFile."</option>";
}
echo "</select>";
echo "<td><input type='submit' name='submitAdd' value='Add'></td>";
echo "</td></tr>";
echo "</form>";
echo "</table>";
?>
<script>
$(document).ready(function() {
$('.mSubIndex').on('input',function() {
var $this = $(this)
if ($this.val()==1) {
$this.closest('form').find('.pageName').prop('disabled','disabled')
}
})
})
</script>