radio單選按鈕選中時當前頁面實現跳轉

例如下面是一個單選的span片段:

<span style="width: 500px;">

<input type="radio" name="chart" value="overAll" checked="checked"/>總體概況
<input type="radio" name="chart" value="interfaceUse"  style="margin-left:35px"/>利用統計 
<input type="radio" name="chart" value="area" style="margin-left:35px"/>地區統計

</span> 

當改變checked屬性時在當前頁面實現跳轉js實現如下:

$('input[type=radio][name=chart]').change(function() {
       if (this.value == 'overAll') {
           window.location.href="${pageContext.request.contextPath}/statisticalAnalysis/overallSituation";
       }else if (this.value == 'interfaceUse') {
           window.location.href="${pageContext.request.contextPath}/statisticalAnalysis/interfaceUse";
       }else if(this.value == 'area'){
        window.location.href="${pageContext.request.contextPath}/statisticalAnalysis/areaSituation";
       }
    });

此爲實現功能的一種方式,記錄下來以後備用查看。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章