Javascript 在html中获取从一个页面到另一个页面的一篇文章的id
我试图从一个页面到另一个页面获取一个对象的id 我有两页Javascript 在html中获取从一个页面到另一个页面的一篇文章的id,javascript,jquery,local-storage,Javascript,Jquery,Local Storage,我试图从一个页面到另一个页面获取一个对象的id 我有两页 index.html 简介.html index.html <input type="text" name="fname" value="" id="idnew"> <a href="intro.html"><input type="button" value="Post" id="butonid"></a> <script> $("#but
- index.html
- 简介.html
<input type="text" name="fname" value="" id="idnew">
<a href="intro.html"><input type="button" value="Post" id="butonid"></a>
<script>
$("#butonid").click(function(){
$('#idnew').val("4")
}
</script>
$(“#butonid”)。单击(函数(){
$('#idnew').val(“4”)
}
现在我想将id idnew的输入值发送到intro.html页面
请帮助我,在加载intro.html之前,val(“4”)设置该元素的值,并与上一页一起丢弃。
要发送该值,您可以完全忘记javascript并使用以下表单:
<form action="intro.html" method="get">
<input type="text" name="idnew" value="">
<input type="submit" value="Submit">
</form>
然后,为了访问该值,例如在php中,使用$\u GET['idnew']使用本地/会话存储来实现这一点,我感到困惑。您能澄清一下您的问题吗?听起来您只需要传递一个变量-这就是表单的用途。请参阅: