我有一个<input type="hidden" class="Key" value="1m2.123.mds.34g" />
如何在不使用 jQuery 的情况下获取值?
使用 jQuery 我只写:
var parse = $('.Key').attr("value")
alert(parse);
我需要纯 JavaScript,也许使用 RegEx?我将在包含此类行的 txt 文件上执行此脚本。
最佳答案
检查这个
window.onload=function(){
var hidden=document.getElementsByClassName("Key");
alert(hidden[0].value);
}
<input type="hidden" class="Key" value="1m2.123.mds.34g" />
关于javascript - 从隐藏字段获取值 - JavaScript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40165651/