onclick和href一起不起作用
onclick and href together not working
我正在创建一个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>
有人能帮我处理这个吗
你可以试试这个:
$(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
}
});
});
onclick="theFunction();"
您不需要return
语句。
添加此target="_blank">锚定标签
<a href="#" onclick="someFuntion()" target="_blank">Text</a>
<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;
}
相关文章:
- Highcharts colorsByPoint与系列中的线性渐变一起使用时不起作用
- 与ng一起使用localstorage Change dons'不起作用
- 为什么 HTML 中的 Value 属性在与 AngularJS 中的 ng-model 一起使用时不起作用
- onClick和onClientClick事件一起使用.在Internet Explorer中不起作用
- FancyBox和自定义工具提示一起使用不起作用
- 可排序的 Js 在带有选择/选项标签的 chrome 中不起作用,但与 ul/li 标签一起工作
- for循环,回调,一起超时,超时似乎不起作用
- jquery settimeout 和 .focus() 一起在 Firefox 浏览器中不起作用
- 如果将php和javascript混合在一起不起作用,请使用简写
- 将装饰为html元素的内容附加在一起;不起作用
- 将两个代码集成在一起时,Javascript函数不起作用
- Raphael悬停函数没有'与其他潜水艇在一起时不起作用
- 与外部javascript一起传递的php脚本不起作用
- Django-将JSON数据和HTML一起传递到前端不起作用
- 当与.html一起使用时,.hooper不起作用
- onclick和href一起不起作用
- 在我将其与$("#id")一起使用后,相同的代码就不起作用了.append.代码看起来像没有加载jq
- 在 photoshop 对话框中将 Javascript 函数参数与 onClick 一起使用不起作用
- 当与绑定一起使用时,KnockoutJS的数据绑定不起作用
- 事件处理-为什么onclick处理程序在javascript中与innerHTML一起使用时不起作用