<table><a href="index.html"><td><a href="index.html">ss</a</td></a></table> 在这个代码片段里,a标签为什么不起效
时间: 2023-08-14 09:38:46 浏览: 143
这是因为在 HTML 中,`<a>` 标签只能作为文本内容的超链接,不能包含其他标签。在你的代码片段中,你试图在一个表格中的单元格内嵌套`<a>`标签,这是不符合 HTML 语法规范的。如果你想在表格中添加超链接,应该将`<a>`标签放到单元格内的文本内容中,而不是尝试嵌套标签。例如:
```
<table>
<tr>
<td><a href="index.html">ss</a></td>
</tr>
</table>
```
这样就可以在表格中添加一个超链接了。
相关问题
<table> <form action="updatePerson.do?personId=${sessionScope.updateById.personId}" method="post"> <tr> <td>姓名:</td> <td><input type="text" name="personName" value="${sessionScope.updateById.personName}"></td> </tr> <tr> <td>称呼:</td> <td> <input type="text" name="personNickName" value="${sessionScope.updateById.personNickName}"></td> </tr> <tr> <td>性别:</td> <td><input type="radio" name="personSex" value="${sessionScope.updateById.personSex}">男<input type="radio" name="personSex" value="${sessionScope.updateById.personSex}">女</td> </tr> <tr> <td> 类别:</td> <td><input type="text" name="kindId" value="${sessionScope.updateById.kindId}"></td> </tr> <tr> <td>生日:</td> <td><input type="text" name="personBirthday" value="${sessionScope.updateById.personBirthday}"></td> </tr> <tr> <td>电话:</td> <td><input type="text" name="personTelephone" value="${sessionScope.updateById.personTelephone}"></td> </tr> <tr> <td>QQ:</td> <td> <input type="text" name="personQQ" value="${sessionScope.updateById.personQQ}"></td> </tr> <tr> <td> 邮箱:</td> <td><input type="text" name="personEmail" value="${sessionScope.updateById.personEmail}"></td> </tr> <tr> <td> 地址:</td> <td> <input type="text" name="personAddress" value="${sessionScope.updateById.personAddress}"></td> </tr> <tr> <td> MSN:</td> <td><input type="text" name="personMSN" value="${sessionScope.updateById.personMSN}"></td> </tr> <tr> <td> 简介:</td> <td><textarea cols="10" rows="5" name="personInfo">${sessionScope.updateById.personInfo}</textarea></td> </tr> <tr> <td><input type="submit" name="重填" value="重填"></td> <td><input type="submit" name="提交" value="提交"></td> </tr> </form> </table>为上述代码设计简单分格的ss和js代码
以下是简单的HTML和JavaScript代码:
HTML代码:
```html
<table>
<form id="updateForm" action="updatePerson.do?personId=${sessionScope.updateById.personId}" method="post">
<tr>
<td>姓名:</td>
<td><input type="text" name="personName" value="${sessionScope.updateById.personName}"></td>
</tr>
<tr>
<td>称呼:</td>
<td><input type="text" name="personNickName" value="${sessionScope.updateById.personNickName}"></td>
</tr>
<tr>
<td>性别:</td>
<td>
<input type="radio" name="personSex" value="男" checked>男
<input type="radio" name="personSex" value="女">女
</td>
</tr>
<tr>
<td> 类别:</td>
<td><input type="text" name="kindId" value="${sessionScope.updateById.kindId}"></td>
</tr>
<tr>
<td>生日:</td>
<td><input type="text" name="personBirthday" value="${sessionScope.updateById.personBirthday}"></td>
</tr>
<tr>
<td>电话:</td>
<td><input type="text" name="personTelephone" value="${sessionScope.updateById.personTelephone}"></td>
</tr>
<tr>
<td>QQ:</td>
<td><input type="text" name="personQQ" value="${sessionScope.updateById.personQQ}"></td>
</tr>
<tr>
<td> 邮箱:</td>
<td><input type="text" name="personEmail" value="${sessionScope.updateById.personEmail}"></td>
</tr>
<tr>
<td> 地址:</td>
<td><input type="text" name="personAddress" value="${sessionScope.updateById.personAddress}"></td>
</tr>
<tr>
<td> MSN:</td>
<td><input type="text" name="personMSN" value="${sessionScope.updateById.personMSN}"></td>
</tr>
<tr>
<td> 简介:</td>
<td><textarea cols="10" rows="5" name="personInfo">${sessionScope.updateById.personInfo}</textarea></td>
</tr>
<tr>
<td><input type="button" name="重填" value="重填" onclick="resetForm()"></td>
<td><input type="button" name="提交" value="提交" onclick="submitForm()"></td>
</tr>
</form>
</table>
```
JavaScript代码:
```javascript
function resetForm() {
document.getElementById("updateForm").reset();
}
function submitForm() {
var form = document.getElementById("updateForm");
if (form.checkValidity()) {
form.submit();
} else {
alert("请完善所有信息!");
}
}
```
其中,resetForm()函数用于重置表单,submitForm()函数用于提交表单。在submitForm()函数中,我们使用了form.checkValidity()方法来检查表单是否完整,如果表单完整,则使用form.submit()方法提交表单,否则弹出提示框提醒用户完善表单信息。
<title>医院住院管理系统</title> </head> <body> <div class="title"> <h2>药品发放</h2> </div> <div class="main"> <form id="drugs_delivery"> <table> <tr> <td> <p class="short-input ue-clear"> <label><font color="red">*</font>住院号:</label> </p> </td> <td> <p class="short-input ue-clear"> <input results="s" type="search" readonly name="patientId" id="patientId" /> </p> </td> <td> <p class="short-input ue-clear"> <label><font color="red">*</font>姓名:</label> </p> </td> <td> <p class="short-input ue-clear"> <input type="text" readonly name="patientName" id="patientName" /> </p> </td> </tr> <tr> <td> <p class="short-input ue-clear"> <label><font color="red">*</font>药品编号:</label> </p> </td> <td> <p class="short-input ue-clear"> <input type="search" results="s" readonly name="drugId" id="drugsId" /> </p> </td> <td> <p class="short-input ue-clear"> <label>数量:</label> </p> </td> <td> <p class="short-input ue-clear"> <input type="text" name="drugCount" id="num" onblur="checkdrugsnum()" /> <input type="hidden" name="num1" id="num1"> <p class="short-input ue-clear"> </td> </tr> <tr> <td> <p class="short-inpue-clear"> <label><font color="red">*</font>药品名称:</label> </p> </td> <td> <p cla
ss="short-input ue-clear"> <input type="text" readonly name="drugName" id="drugsName" /> </p> </td> <td> <p class="short-inpue-clear"> <label>规格:</label> </p> </td> <td> <p class="short-input ue-clear"> <input type="text" readonly name="drugSpec" id="drugsSpec" /> </p> </td> </tr> <tr> <td> <p class="short-input ue-clear"> <label>剂量:</label> </p> </td> <td> <p class="short-input ue-clear"> <input type="text" readonly name="drugDosage" id="drugsDosage" /> </p> </td> <td> <p class="short-input ue-clear"> <label>单位:</label> </p> </td> <td> <p class="short-input ue-clear"> <input type="text" readonly name="drugUnit" id="drugsUnit" /> </p> </td> </tr> <tr> <td colspan="4"><label><font color="red">*</font>用法用量:</label><textarea rows="3" cols="30" name="drugUsage"></textarea></td> </tr> <tr> <td> <p class="short-input ue-clear"> <label>医生:</label> </p> </td> <td> <p class="short-input ue-clear"> <input type="text" readonly name="doctorName" id="doctorName" /> </p> </td> <td> <p class="short-input ue-clear"> <label>发放人:</label> </p> </td> <td> <p class="short-input ue-clear"> <input type="text" readonly name="deliveryName" id="deliveryName" value="自动填写" /> </p> </td> </tr> </table> <div class="btn"> <div class="button"> <p class="submit"> <input type="submit" value="确定" id="delivery_submit" /> </p> </div> </div> </form> </div> </body> </html>
阅读全文