js实现select跳转功能代码
更新时间:2014年10月22日 17:04:44 投稿:whsnow
实现select跳转的方法有很多,本例为大家介绍的是js实现的,通过location.href获取跳转地址,需要的朋友可以看看
js简单实现select跳转功能:代码如下
<!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>
相关文章
JS触发事件event.target VS event.currentTarget实例
这篇文章主要介绍了JS触发事件event.target VS event.currentTarget实例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2023-10-10javascript对下拉列表框(select)的操作实例讲解
这篇文章主要介绍了javascript对下拉列表框(select)的操作。需要的朋友可以过来参考下,希望对大家有所帮助2013-11-11重学 JS:为啥 await 不能用在 forEach 中详解
这篇文章主要介绍了重学 JS:为啥 await 不能用在 forEach 中,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2019-04-04
最新评论