我正在使用jQuery滾動條滾動到頁面上的某個元素。在這種情況下,它是Navbar。不過,我遇到了一個奇怪的問題。點擊按鈕滾動到元素後,結果元素將生成focus
屬性。平滑滾動生成:目標div上的活動屬性
這會消失,當我點擊並取消勾選元素再次出現。它只發生在我點擊按鈕滾動到這個位置之後。我曾嘗試針對重點標籤div和它聲明.navbar:focus { box-shadow: none;}
但它不工作
我使用下面的產生的滾動效應,感到 <a href="#navigationtop" class="anchorLink">
jQuery(function($) {
var scrollElement = 'html, body';
$('html, body').each(function() {
var initScrollTop = $(this).attr('scrollTop');
$(this).attr('scrollTop', initScrollTop + 1);
if ($(this).attr('scrollTop') == initScrollTop + 1) {
scrollElement = this.nodeName.toLowerCase();
$(this).attr('scrollTop', initScrollTop);
return false;
}
});
// Smooth scrolling for internal links
$("a[href^='#']").click(function(event) {
event.preventDefault();
var $this = $(this),
target = this.hash,
$target = $(target);
$(scrollElement).stop().animate({
'scrollTop': $target.offset().top
}, 500, 'swing', function() {
window.location.hash = target;
});
});
});
你是什麼意思'結果元素生成焦點屬性'? – MElliott
有沒有這樣的事情作爲一個HTML元素的'焦點'屬性..以及如何一個元素爲自己生成一個屬性?沒有意義。 – MElliott
多數民衆贊成最好的方式,我可以形容它.....當我點擊它,它添加我認爲,一個盒子的影子,但只有在按鈕滾動已被預先 – memyselfandmyiphone