当我通过 url:www.domain.com/#ratings 时,评级选项卡应该打开,现在它在 url 中显示当前选项卡,但不适用于链接选项卡
<script type="text/javascript">
$(document).ready(function () {
$('.tabs a').click(function () {
switch_tabs($(this));
});
switch_tabs($('.defaulttab'));
});
function switch_tabs(obj) {
$('.tab-content').hide();
$('.tabs a').removeClass("selected");
var id = obj.attr("rel");
$('#' + id).show();
obj.addClass("selected");
}
</script>
<ul class="tabs">
<li>
<a href="#movies" class="defaulttab" rel="movies">Tutorial</a>
</li>
<li>
<a href="#ratings" rel="ratings">Comments</a>
</li>
</ul>
<div class="contentbox">
<div class="tab-content" id="movies">movie tab</div>
<div class="tab-content" id="ratings">rating tab</div>
</div>