【发布时间】:2017-09-19 20:25:05
【问题描述】:
我在 page1(www.example.com/page2.html#idd) 中有一个链接指向 page2 中的锚标记 当我点击 page1 中的链接(www.example.com/page2.html#idd)时,我只是转到 page2(www.example.com/page2.html)而不是 #idd。 我认为“js”文件有问题,但我不知道是什么!
"index.js"
$('.form').find('input, textarea').on('keyup blur focus', function (e) {
var $this = $(this),
label = $this.prev('label');
if (e.type === 'keyup') {
if ($this.val() === '') {
label.removeClass('active highlight');
} else {
label.addClass('active highlight');
}
} else if (e.type === 'blur') {
if( $this.val() === '' ) {
label.removeClass('active highlight');
} else {
label.removeClass('highlight');
}
} else if (e.type === 'focus') {
if( $this.val() === '' ) {
label.removeClass('highlight');
}
else if( $this.val() !== '' ) {
label.addClass('highlight');
}
}
});
$('.tab a').on('click', function (e) {
e.preventDefault();
$(this).parent().addClass('active');
$(this).parent().siblings().removeClass('active');
target = $(this).attr('href');
$('.tab-content > div').show();
$(target).fadeIn(600);
});
这里是html文件:
"page1.html"
<div> <a href="example.com/page1.html#idd">click here</a>
"page2.html"
<div id="idd">content......</div>
【问题讨论】:
-
Java 不是 JavaScript
标签: javascript html css