我很困惑。我在.title上实现了一个click()函数来切换其兄弟(表)是否显示或隐藏。这工作正常。我的问题是,我在标签上有另一个点击功能.title。当我点击一个标签时,我想让表格打开,但是.title覆盖了它,并关闭它并将所有东西混淆。目前,我在一个标签上有一个onClick()(它仍然不起作用),它是通过jQuery .click()完成的,但我无法正确地完成它。jQuery .click()覆盖标签
<script>
function dateChange(boatInput, dateInput){
$("table").first().children().remove();
$("table").first().load("availability.asp?boatType="+ boatInput +"&date="+ dateInput +"");
}
$(document).ready(function() {
$("table").first().load("availability.asp?boatType=PowerCatamaran&date=currentDate", function(response, status, xhr){
if (status == "error") {
var msg = "Sorry but there was an error: ";
$("table").html(msg + xhr.status + " " + xhr.statusText);
}
});
$(".title").click(function(){
$(this).next().toggleClass("hide");
var boatName = $(this).next().attr('id');
if(!$(this).next().hasClass('hide')){
if(boatName == "SailingCatamaran"){
$(this).next().load("#");
}
else if(boatName == "PowerCatamaran"){
$(this).next().load("#");
}
else{
$(this).next().load("#");
}
}
$(this).children().last().toggleClass("hide");
$(this).find('.dateSelect').toggleClass("hide");
});
});
</script>
<div class="title">
<h2>Catamarans</h2>
<div class="dateSelect">
<div class="prev">
<p>Prev</p>
<a href="#">< month</a>
<a href="#">< week</a>
<a href="#">< day</a>
</div>
<div class="next">
<p>Next</p>
<a href="#" onClick="dateChange('PowerCatamaran', 'nextMonth')">month ></a>
<a href="#">week ></a>
<a href="#">day ></a>
</div>
</div>
<div class="expand hide">
Click to Expand
</div>
</div>
到目前为止,代码是静态的。在完全动态化之前,我只需要一些实际的功能。我提前为可怕的代码道歉!
@AkiraDawson没有,里面的一个。你可以分享标签点击事件代码 –
圣诞节它的工作!你是个天才!!!! –
如果你曾经击中过澳元,我会给你买一瓶该死的啤酒。 –