<select>的選擇事件onchange


<select>的選擇事件onchange


本人在學習TP5.1做網站時想做到通過選擇<select>標籤中的<option>來訪問相應的網站。/<option>/<select>

今天終於實現了這個功能,通過onchange事件和JS中的 $('#s_class option:selected').val()來獲取相應的值,再利用window.location.href來訪問

HTML部分

<code><select>

<option>選擇班級/<option>

{volist name='classlist' id='cvo'}

<option>{$cvo.name}/<option>

{/volist}

/<select> /<code>

JS部分

<code>\t\tfunction selectClass() {
\t\t\tvar u = $('#s_class option:selected').val();
\t\t\twindow.location.href = "{:url('studentList')}" + "?class=" + u;
\t\t}
\t\t/*用戶-刪除*//<code>


分享到:


相關文章: