我有一个关于Language School网站的项目。它有很多经销商。
如果用户选择经销商,请点击我们,我想重定向到SELECTED经销商的关于我们页面。
如何使用jQuery解决此问题?
谢谢
<div class="blueBox">
<h2 class="title">Dealers</h2>
<span class="sortArea clearfix">
<a href="#" class="blueBt Bt">All Dealers</a>
<!--scroll dropdown-->
<form >
<select id="e1">
<option value="Education Center">Education Center</option>
<option value="Yenimahalle">Yenimahalle</option>
<option value="Demetevler">Demetevler</option>
</select>
</form>
<!--scroll dropdown-->
</span>
<div class="detail clearfix">
<h3 class="subTitle">Şube Seçiniz</h3>
<ul class="detailLinks">
<li><a class="one Bt" href="#">About US</a></li>
<li><a class="two Bt" href="#">Pictures</a></li>
<li><a class="three Bt" href="#">Personal</a></li>
<li><a class="four Bt" href="#">Contact Us</a></li>
</ul>
</div>
</div>
答案 0 :(得分:2)
如果您有经销商的选项列表,并且您希望点击关于我们的信息 转到右侧页面查看这个简单的代码
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://pvp.comeze.com/cms/js/jquery.dotdotdot.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('select').on('change',function(){
var links=$('#dealers option:selected').attr('value')
if(links){
$('#about').attr('href',links)
}
})
})
</script>
</head>
<body>
<select id="dealers">
<option>select</option>
<option value="about us1.html">dealer 1</option>
<option value="about us2.html">dealer 2</option>
<option value="about us3.html">dealer 3</option>
</select>
<a href="" id="about">about us</a>
</body>
</html>
答案 1 :(得分:1)
$("#aboutUsLink").click(function(){
selected = $("option:selected","#e1").attr("value");
window.location.href = aboutPage(selected);
})