未捕獲的錯誤。語法錯誤,未識別的運算式。[href=#technical]
tabs.js檔案
$(function(/span>) {
var tab = $('.tab a') 。
content = $('.tab-content') 。
if ( location.hash ) {
tab.filter('[href=' location. hash ']').addClass('active'/span>)。
content.hide().filter(location. hash).show().fadeIn()。
} else {
tab.filter(':first').addClass('active') 。
content.filter(':not(:first)').hide() 。
}
tab.click(function(/span>) {
if( location.hash ){
var id = location.hash;
} else {
var id = $(this).attr('href') 。
}
tab.removeClass('active')。 filter('[href=' id ']')。addClass('active')。
content.hide().filter(id).show()。
});
$(window).bind('hashchange', function(){
tab.trigger('click')。
});
});
tabs.php檔案
<div class="tab">/span>
<a href="#overview"/span>> Overview</a>。
<a href="#features"/span>> Features</a>。
<a href="#articles"/span>> Articles</a>。
<a href="#technical"/span>> 技術</a>
</div>/span>
< div id="概述" class="標簽-內容">
<p>echo...</p>
</div>/span>
< div id="features" class="tab-content">
<p>echo...</p>
</div>/span>
< div id="articles" class="tab-content">
<p>echo...</p>
</div>/span>
< div id="technical" class="tab-content">
<p>echo...</p>
</div>
為什么我有這樣的問題?當我激活舊版本時,它是有效的,但當我試圖更新時,我有一個問題。
uj5u.com熱心網友回復:
這似乎是一個報價問題。你有:
tab.removeClass('active'/span>)。 filter('[href=' id '').addClass('active')。
所以選擇器變成:
[href=#overview]/span>
我相信你想把選擇器改成下面的樣子:
[href='#overview']
考慮以下情況。
。$(function() {
var tab = $('.tab a') 。
content = $('.tab-content') 。
if (location.hash) {
tab.filter("[hrefa'" location. hash "']").addClass('active')。
content.hide().filter(location. hash).show().fadeIn()。
} else {
tab.filter(':first').addClass('active') 。
content.filter(':not(:first)').hide() 。
}
tab.click(function(/span>) {
if (location.hash) {
var id = location.hash;
} else {
var id = $(this).attr('href') 。
}
tab.removeClass('active')。 filter("[href='" id "']").addClass('active') 。
content.hide().filter(id).show()。
});
$(window).on('hashchange', function() {
tab.trigger('click')。
});
});
< link rel="styleheet" href="/code. jquery.com/ui/1.12.1/themes/base/jquery-ui.css">/span>
<script src="https://code. jquery.com/jquery-3.6.0.js"></script>
<script src="https://code. jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div class="tab">/span>
<a href="#overview"/span>> Overview</a>。
<a href="#features"/span>> Features</a>。
<a href="#articles"/span>> Articles</a>。
<a href="#technical"/span>> 技術</a>
</div>/span>
< div id="概述" class="標簽-內容">
<p>echo...</p>
</div>/span>
< div id="features" class="tab-content">
<p>echo...</p>
</div>/span>
< div id="articles" class="tab-content">
<p>echo...</p>
</div>/span>
< div id="technical" class="tab-content">
<p>echo...</p>
</div>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" class="snippet-box-edit snippet-box-result" frameborder="0"></iframe>
這不會產生你報告的錯誤。
這不會產生你報告的錯誤。
uj5u.com熱心網友回復:
Jquery 3.0廢棄的系結函式
// your code
$(window).bind('hashchange', function() {
tab.trigger('click')。
});
//改為
$(window).on('hashchange', function() {
tab.trigger('click')。
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/319933.html
標籤:
