<div>
<select id='s1' οnchange='ChangePageItem(this);'>
<option value='10'>10</option>
<option value='30'>30</option>
<option value='50'>50</option>
<option value='100'>100</option>
</select>
</div>
<script src='/static/jquery-1.8.2.js'></script>
<script src='/static/jquery.cookie.js'></script>
<script type='text/javascript'>
$(function(){
var per_item = $.cookie('pager_num')
if(per_item){
$('#s1').val(per_item)
}
})
function ChangePageItem(arg){
var value = $(arg)
$.cookie('pager_num', value,{path: '/index/'});
}
</script>
在 views.py里面获取cookie
def index(request,page):
per_item = request.COOKIES.get('pager_num',10) #必须是整数
<select id='s1' οnchange='ChangePageItem(this);'>
<option value='10'>10</option>
<option value='30'>30</option>
<option value='50'>50</option>
<option value='100'>100</option>
</select>
</div>
<script src='/static/jquery-1.8.2.js'></script>
<script src='/static/jquery.cookie.js'></script>
<script type='text/javascript'>
$(function(){
var per_item = $.cookie('pager_num')
if(per_item){
$('#s1').val(per_item)
}
})
function ChangePageItem(arg){
var value = $(arg)
$.cookie('pager_num', value,{path: '/index/'});
}
</script>
在 views.py里面获取cookie
def index(request,page):
per_item = request.COOKIES.get('pager_num',10) #必须是整数