Javascript 如何获取pagechange函数中传递的参数值

Javascript 如何获取pagechange函数中传递的参数值,javascript,jquery,html,Javascript,Jquery,Html,我有一个按钮,就像 <button class="cart" onclick="allow(this)" data-val="134" data-pcode="sdfghj"> car</button> 对于receive和allow.html页面,我使用 $(document).on( "pageinit", "#viewandgift", function( e ) { console.log("pag

我有一个按钮,就像

 <button class="cart" onclick="allow(this)" data-val="134" data-pcode="sdfghj">
                           car</button>
对于receive和allow.html页面,我使用

$(document).on( "pageinit", "#viewandgift", function( e ) {
    console.log("page loaded view and gift wala");
    var passedId = (($(this).data("url").indexOf("?") > 0) ? $(this).data("url") : window.location.href ).replace( /.*value=/, "" );
    $("#details").html(["Selected id is: '", passedId, "'"].join(""));
    console.log("--------------------------");
    console.log(passedId);
});
在第二页提取值的正确方法是什么?解析URL不是一个好的选择。

什么是
#view和gift
,它来自哪里?当您使用jQuery时,为什么不使用
$('.cart')
$(document).on( "pageinit", "#viewandgift", function( e ) {
    console.log("page loaded view and gift wala");
    var passedId = (($(this).data("url").indexOf("?") > 0) ? $(this).data("url") : window.location.href ).replace( /.*value=/, "" );
    $("#details").html(["Selected id is: '", passedId, "'"].join(""));
    console.log("--------------------------");
    console.log(passedId);
});