2016-05-31 72 views

回答

2

window.location.hash包含#加上#本身后的片段

只是用它作为选择和设置checked属性

$(function() { 
    $(window.location.hash).prop("checked", true); 
}) 
1
//var url = 'sitelink.com/page#example'; 
var anchor = window.location.hash.substring(1); 

$('input[type=checkbox][value="'+anchor +'"]').prop("checked",true); 
1
var link = document.location.href.split('#'); 
if(link.length==2) 
{ 
    var id = '#' + link[1]; 
    if($(id).length!=0) 
     $(id).attr('checked',true); 
} 
上匹配的复选框
相关问题