Javascript Html<;选择>;要在默认情况下隐藏并启用按钮操作吗
默认情况下,我尝试隐藏Javascript Html<;选择>;要在默认情况下隐藏并启用按钮操作吗,javascript,html,Javascript,Html,默认情况下,我尝试隐藏,当我单击编辑按钮时,我想显示它。但它并不像预期的那样工作 请在下面找到我的代码 <!DOCTYPE html> <html> <head> <script> function update_country() { if(document.getElementById("Editbtn").value == 'Edit'){ document.getEleme
,当我单击编辑
按钮时,我想显示它。但它并不像预期的那样工作
请在下面找到我的代码
<!DOCTYPE html>
<html>
<head>
<script>
function update_country() {
if(document.getElementById("Editbtn").value == 'Edit'){
document.getElementById("country").style.display = 'none';
document.getElementById("Editbtn").value = "Update";
document.getElementById("countries").style.visible = 'true';
}
}
</script>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<h2>HTML Table</h2>
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td id="country">Germany</td>
<td id="countryOption" visible =false>
<select name="countries" id="countries" >
<option value="Germany">Germany</option>
<option value="India">India</option>
<option value="France">France</option>
<option value="Italy">Italy</option>
</select>
<input id="Editbtn" type="button" value="Edit" onclick="update_country()">
</td>
</tr>
</table>
</body>
</html>
Am trying to modify `Country` column by click on the `edit` button. once i clicked on edit button existing `<td>` tag should be hidden and `select>` tag should be visible to select other country and update the column by clicking on the `udpate` button
功能更新_country(){
if(document.getElementById(“Editbtn”).value==“Edit”){
document.getElementById(“country”).style.display='none';
document.getElementById(“Editbtn”).value=“更新”;
document.getElementById(“国家”).style.visible='true';
}
}
桌子{
字体系列:arial,无衬线;
边界塌陷:塌陷;
宽度:100%;
}
td,th{
边框:1px实心#dddddd;
文本对齐:左对齐;
填充:8px;
}
tr:n个孩子(偶数){
背景色:#dddddd;
}
HTML表格
单位
接触
国家
阿尔弗雷德·福特基斯特
玛丽亚·安德斯
德国
德国
印度
法国
意大利
我试图通过点击“编辑”按钮来修改“国家”列。单击编辑按钮后,现有的``标记应隐藏,`选择>`标记应可见,以选择其他国家/地区,并通过单击` udpate`按钮更新列
非常简单,只需在select上添加内联style='display:none'
,然后使用js进行更改,如:
功能更新_country(){
if(document.getElementById(“Editbtn”).value==“Edit”){
document.getElementById(“country”).style.display='none';
document.getElementById(“Editbtn”).value=“更新”;
document.getElementById(“countries”).style.display='inline block';
}
}
桌子{
字体系列:arial,无衬线;
边界塌陷:塌陷;
宽度:100%;
}
td,th{
边框:1px实心#dddddd;
文本对齐:左对齐;
填充:8px;
}
tr:n个孩子(偶数){
背景色:#dddddd;
}
HTML表格
单位
接触
国家
阿尔弗雷德·福特基斯特
玛丽亚·安德斯
德国
德国
印度
法国
意大利
感谢它工作得很好。我们如何才能在下拉列表
元素的右侧使用更新
按钮。