我不明白为什么这个脚本不会在第一次点击事件后触发。 show()函数完美工作,但hide()不起作用。jquery show()/隐藏()第一次点击后没有触发
<script type="text/javascript">
$(document).ready(function() {
$(".event.hidden").click(function() {
var div_id = this.id.replace(/But/, 'Div');
$("#" + div_id).show('slow', 'linear');
$(this).attr("src", "images/but_hide_event.png");
$(this).removeClass('hidden').addClass('shown');
});
$(".event.shown").click(function() {
var div_id = this.id.replace(/But/, 'Div');
$("#" + div_id).hide('slow');
$(this).attr("src", "images/but_event_info.png");
$(this).removeClass('shown').addClass('hidden');
});
});
</script>
页中的问题是在http://randykrohn.com/schedules.php?Param=all
你”重新选择东西效率低下。你不应该像这样两次重复相同的代码,只是改变的部分。如果你考虑如何重新设计它,答案应该很明显。 – Incognito 2010-12-11 04:19:11