我正在创建一个html页面,我有三个选项卡点击选项卡我想让它活跃,我也想转到其他页面 这是我的代码
<div class="col-sm-3 text-center sprtr-1">
<a class="tab-link" href="#events?eventType=Movies&industry={{selectedIndustry.name}}" onclick="return theFunction();" i18n="EVENT.MOVIES"><span class="glyphicon glyphicon-facetime-video"></span> MOVIES</a>
</div>
<div class="col-sm-3 text-center sprtr-1">
<a class="tab-link" href="#events?eventType=Performance&industry={{selectedIndustry.name}}" i18n="EVENT.PERFORMANCES"><span class="glyphicon glyphicon-leaf"></span> PERFORMANCES</a>
</div>
<div class="col-sm-3 text-center sprtr-1">
<a class="tab-link" href="#events?eventType=WorkShops&industry={{selectedIndustry.name}}" i18n="EVENT.WORKSHOPS"><span class="glyphicon glyphicon-gift"></span> WORKSHO PS</a>
</div>
这是我的脚本
<script type="text/javascript">
function theFunction() {
alert("dfsdf");
if(!$(this).hasClass("active")){
$(".active").removeClass("active");
$(this).addClass("active");
}else{
return false;//this prevents flicker
}
}
</script>
有人可以帮助我吗
答案 0 :(得分:0)
你可以试试这个:
$(document).ready(function(){
$('.tab-link').click(function(){
alert("dfsdf");
if(!$(this).hasClass("active")){
$(".active").removeClass("active");
$(this).addClass("active");
}else{
return false;//this prevents flicker
}
});
});
答案 1 :(得分:0)
onclick="theFunction();"
您不需要return
声明。
答案 2 :(得分:0)
<a class="tab-link" href="#events?eventType=Movies&industry={{selectedIndustry.name}}" onclick="theFunction(); return true" i18n="EVENT.MOVIES"><span class="glyphicon glyphicon-facetime-video"></span> MOVIES</a>
它适用于你
或
<a class="tab-link" href="#events?eventType=Movies&industry={{selectedIndustry.name}}" onclick="return theFunction();" i18n="EVENT.MOVIES"><span class="glyphicon glyphicon-facetime-video"></span> MOVIES</a>
function theFunction(event) {
event.preventDefault();
alert("dfsdf");
if(!$(this).hasClass("active")){
$(".active").removeClass("active");
$(this).addClass("active");
}else{
return false;//this prevents flicker
}
return true;
}
答案 3 :(得分:0)
添加此内容 target =“_ blank”来锚定标记
<a href="#" onclick="someFuntion()" target="_blank">Text</a>