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

js implements select jump function code_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:33:021323browse

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> 
Statement:
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