2013-12-15 184 views
0

我特林加載結果頁面真實的複選框的名單上加載頁面

我這裏有這個代碼 - http://css-tricks.com/dynamic-page-replacing-content/

和我想要做的財產以後這樣的:

$("#form_id").delegate("input", "click", function() { 
    window.location.hash = $(this).attr("href"); 
    return false; 
}); 

,但我在url結束了 - #undefined

我的形式是:

<form name="search" action="" method="get" id="search_form"> 

    <div class="fluid"> 
     <div style="padding-right: 5px; ">   

         <label> computer <input class="chkd" type="checkbox" checked="checked" name="category[]" value="computers"> </label> 
         <label> computer <input class="chkd" type="checkbox" checked="checked" name="category[]" value="computers1"> </label> 
         <label> computer <input class="chkd" type="checkbox" checked="checked" name="category[]" value="computers2"> </label> 

    </div> </div> 
</form> 

有什麼想法?

+0

什麼是您的HTML? 'input'沒有'href'屬性。 – Salman

回答

0

原創文章用途:

$("nav").delegate("a", "click", function() { 
     window.location.hash = $(this).attr("href"); 
     return false; 
    }); 

意味着它是指在nava標籤。但在你的代碼中,似乎你正在試圖獲得inputhref。這是不可能的。

試試這個:而不是

window.location.hash = $("nav a").attr("href"); 

window.location.hash = $(this).attr("href"); 

只是指向右a標籤。

+0

我上面添加了我的表單代碼,我沒有在我的代碼中「導航」 –

+0

@Yaakov你想達到什麼目的?用複選框的值更新哈希值? 然後,這可能有助於: 'window.location.hash = $(this).val();' – Moin

+0

也代替'$(「#form_id」)'使用'$(「#search_form」)' – Moin