Home > Web Front-end > JS Tutorial > js implements select jump function code_javascript skills

js implements select jump function code_javascript skills

WBOY
Release: 2016-05-16 16:33:02
Original
1348 people have browsed it

JS simply implements the select jump function: the code is as follows

<!DOCTYPE html> 
<html> 
<head> 
<title></title> 

</head> 
<body> 
<div class="selectBox"> 
<select class="toSlt"> 
<option href="http://jichuang.gongchang.cn/pro-161264/">全部分类的商品</option> 
<option href="http://jichuang.gongchang.cn/">普通车床</option> 
<option href="http://jichuang.gongchang.cn/brand/">回转车床</option> 
<option href="http://jichuang.gongchang.cn/">普通车床</option> 
<option href="http://jichuang.gongchang.cn/brand/">回转车床</option> 
</select> 
</div> 
<script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script> 
<script type="text/javascript"> 

$(function(){ 
var $body = $('body'); 
$body.on('change', 'select:has(option[href])', function(e) { 
var _this = $(this), 
_href = _this.find('option:selected').attr('href');//获取要跳转的地址 
location.href = _href; //跳转 
}) 
}) 

</script> 
</body> 
</html> 
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template