每次单击下一步按钮时,我将如何使用 ?m=11&y=2014 更新查询字符串


How would I update the query string with ?m=11&y=2014 every time I clicked on next button?

--header--

<div class="table-header-wrapper">
                <div class="prev"></div>
                <div class="year"><?php echo $current_year; ?></div>
                <div class="next"></div>
            </div>
-

-PHP选项卡式月份代码--

<?php
    for ($monthNum = 1; $monthNum <= 12; $monthNum++) :
        $month = date('M', mktime(0, 0, 0, $monthNum, 1, $current_year)); // month in 3 letter format e.g. Jan
        $current_monthNum = date('n'); // current month in number
        ?>
        <div class="<?php echo strtolower($month); ?> month" data-month="<?php echo $monthNum; ?>">
            <a href="<?php echo home_url('admin-events-list') . '/?' . addQuery(array('m' => $monthNum, 'y' => $current_year)); ?>" class="<?php echo ( $current_monthNum == $monthNum ? 'current' : '' ); ?>"><?php echo $month; ?></a>
        </div>
        <?php
    endfor;
?>

=== HTML结构 ===

<2014>

[1月] [2月] [

3月] [4月]...等

?m=11&y=2014单击下一个按钮时的 y 变量增量。

-

-header-- 上的按钮增加/减少 1,并且还会更新月份选项卡 href 中的查询字符串,例如 domain.com/?m=11&y=2014 如果单击下一个 domain.com/?m=11&y=2015。任何帮助将不胜感激。

这将简单地更新年度的innerHTML,但您可以根据需要更改功能:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="prev" onclick="$('#year').html(parseInt($('#year').html())-1);$('.month').each(function(e, obj){obj.href=obj.href.substr(0,obj.href.length-4)+$('#year').html()})">PREVIOUS</div>
<div class="year" id="year">2014</div>
<div class="next" onclick="$('#year').html(parseInt($('#year').html())+1);$('.month').each(function(e, obj){obj.href=obj.href.substr(0,obj.href.length-4)+$('#year').html()})">NEXT</div>
<div id="months"><a class="month" href="domain.com/?m=09&y=2014">sep</a>&nbsp;<a class="month" href="domain.com/?m=10&y=2014">oct</a>&nbsp;<a class="month" href="domain.com/?m=11&y=2014">nov</a>&nbsp;</div>