获取相同html中的hidden字段的值? [英] Get the value of hidden field in same html?

查看:34
本文介绍了获取相同html中的hidden字段的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在HTML中获取 hidden 字段的值.

I want to get the value of hidden field in my html.

<form>

<fieldset>
<input id="name" type="hidden" value="vikiiii" name="name">
</fieldset>

My name is {What should i write here to print "vikiiii" ???} ...!!!

</div>

</form>

我如何在相同的html中打印我的名字.

How i can print my name in that same html.

我该如何做到这一点?预先感谢.

How i can achieve this? Thanks in advance.

推荐答案

假设此HTML

<form>

<fieldset>
<input id="name" type="hidden" value="vikiiii" name="name">
</fieldset>

My name is <span id="nameTarget"></span> ...!!!

</div>

</form>

此JavaScript代码将起作用:

This JavaScript code will work:

document.getElementById( 'nameTarget' ).innerHTML = document.getElementById( 'name' ).value;

这篇关于获取相同html中的hidden字段的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆