我应该在我的jQuery函数中写什么来从我的inputfield(id = btnCloseDeal)获取值并将其显示在另一个页面上?

时间:2012-11-15 18:02:07

标签: javascript jquery html

在输入字段中输入/写入名称(id = btnCloseDeal),然后点击我的GoToPayBtn Im进入新页面。在我的新页面上,我想从我的inputfield(id = btnCloseDeal)获取值并显示它。我应该在我的jQuery函数中写什么来从我的inputfield(id = btnCloseDeal)获取值并将其显示在另一个页面上?

 <input type="button" class="artikel" id="btnCloseDeal" value="Pay" onclick="check();";"/>

$("#btnCloseDeal ").click(function (){}

2 个答案:

答案 0 :(得分:0)

正如我理解你的问题,你想要实现它的方式并不是最佳的。

我建议使用你的字段(#btnCloseDeal)作为查询参数,然后用jQuery获取它。

这是一个函数,它将为您提供纯JS

中的查询参数
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
if(results == null)
  return "";
else
  return decodeURIComponent(results[1].replace(/\+/g, " "));
}

答案 1 :(得分:0)

您可以将输入值设置为您要重定向到的网页的网址,然后在该网页上使用javascript获取url参数:

// get the url
var url = window.location.protocol + "//" + window.location.host;

并使用:

var param = location.search;