如何在jQuerymobile中将多按钮点击变量传递到下一页


How to pass multiple button click variable to next page in jQuery mobile?

如何在jQuery mobile中通过按钮点击将变量传递到下一页?

<div class="left_container w3-ul w3-card-4">
    <div class="post-meta">
        <h4 style="text-align:left;padding-top:5px;margin-left:20px;">Engineering</h4>
    </div>
    <ul>
        <li><a href="dept.php?dep=Civil&page=1">Civil</a></li>
        <li><a href="dept.php?dep=Chemical&page=1">Chemical</a></li>
        <li><a href="dept.php?dep=Computer&page=1">Computer</a></li>
    </ul>

假设您正在完全重新加载页面,则必须拦截点击事件并手动重定向。类似的东西

$(".post-meta a").click(function(e){
    e.preventDefault();  //Stop the link from firing normally.
    var location = $(this).attr('href');
    location += "&var1=" + var1 + "&var2=" + var2;
    window.location = location;
});

如果现有链接没有查询变量,您可以用?而不是&作为前缀。你可以做一个基本的子字符串检查,看看你应该使用哪个前缀。由于您的示例已经在每个上都有一个查询var,我假设您可以假设您总是有一个?