如何在JavaScript中获取下一个元素并进行更新

时间:2015-03-08 14:34:45

标签: javascript

我有以下代码:

<td>
<input type="button" name="btndelete" value="Delete" onclick="Delete(this)" />
<input type="hidden" name="hiddentxt" value="1" />
</td>

我想点击btndelete按钮时更新隐藏的字段值。 我想仅使用纯javascript更新值,也不能为隐藏字段提供id。

我尝试过如下:

function Delete(e){
    // I have other logic scripts.

    e.nextSibling.innerHTML = "updated value";
    }
}

但无法更新。请帮助。

1 个答案:

答案 0 :(得分:0)

function Delete(e){
    // I have other logic scripts.

    e.nextSibling.value = "updated value";
    }
}

您需要更新输入DOM节点的值