我們可以用jquery達到這個目標:
function remember( selector ){ $(selector).each( function(){ //if this item has been cookied, restore it var name = $(this).attr('name'); if( $.cookie( name ) ){ $(this).val( $.cookie(name) ); } //assign a change function to the item to cookie it $(this).change( function(){ $.cookie(name, $(this).val(), { path: '/', expires: 6 }); } ); } ); } $(document).ready( function(){ if($.cookie('host')=='ptt2') $("#host_ptt2").attr("checked","checked"); else $("#host_ptt").attr("checked","checked"); remember('[name=ptt_ID]'); remember('[name=aid]'); remember('[name=board]'); } );本文未完成,有待補完
沒有留言:
張貼留言