例如下面是一個單選的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";
}
});
此爲實現功能的一種方式,記錄下來以後備用查看。