在输入字段(id=btnCloseDeal)中输入/写入名称时,然后单击我的GoToPayBtn,我将进入一个新页面。在我的新页面上,我想从我的输入字段(id=btnCloseDeal)中获取值并显示它。我应该在jQuery函数中写些什么来从我的inputfield(id=btNCloseDeall)中获得值并在另一个页面上显示它?
<input type="button" class="artikel" id="btnCloseDeal" value="Pay" onclick="check();";"/>
$("#btnCloseDeal ").click(function (){}
正如我理解您的问题,您考虑实现它的方式不是最佳的。
我建议使用您的字段(#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, " "));
}
您可以将输入值设置为要重定向到的页面的url,然后在该页面上使用javascript获取url参数:
// get the url
var url = window.location.protocol + "//" + window.location.host;
和用途:
var param = location.search;