作者sin282 (@兴...)
看板Ajax
标题[问题] jQuery Tabs 使用innerhtml改变div问题
时间Sat Dec 22 14:36:10 2012
请教一下大家,为什麽我用innerhtml替换tabs页签後
假设tabs3有3个页签~ tabs3-2&tabs3-3无法点选
自己真的太浅了~ 拜托大家
有查以前tabs的文章, 3131篇Unifish大大有说过几个问题~(这里因需求 我不能重整网页)
所以我有测了一些作法,但还是无法正常运作,以下是问题描述...
---------------------问题描述Start-----------------------
web中使用了jQuery Tabs页签
<div id="father">
<div id="tabs">
|
tabs 1 2 3的初始页签
|
</div>
</div>
因为专案需求~ 所以可能点了某个连结後,会替换father里的内容
所以我采用了
Loadtabs="<div id=\"tabs3\">"+
|
tabs3-1 ~3-n的页签内容(应该是没有bug)
|
"</div>"
document.getElementById('father').innerHTML = Loadtabs;
此时发现如果很早就宣告
$( "#tabs" ).tabs();
$( "#tabs2" ).tabs();
$( "#tabs3" ).tabs();
页签的切换页Link会像这样
.tabs3-1
.tabs3-2
.tabs3-3
Content
所以我将$( "#tabs3" ).tabs(); 放在innerhtml後面~
但这样子虽然页签的样子CSS出来了
但是切换tabs3-2 & 3-3会无法改变内容,并跑出
jQuery jquery-1.8.2.js 477行惊叹号
error: function( msg ) { throw new Error( msg ); },
------------------------问题结束---------------------------
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 218.210.231.212
※ 编辑: sin282 来自: 218.210.231.212 (12/22 14:36)
※ 编辑: sin282 来自: 218.210.231.212 (12/22 15:09)
1F:→ qwer820404:看要不要放个example 在jsfiddle上面 直接帮你看看 12/22 15:49
2F:→ sin282:目前解是先直接换 tabs3-1 3-2 3-3 而不是换掉整个Tabs3 12/22 16:06
3F:→ sin282:qwer大您是好人... 12/22 16:10
4F:推 mrbigmouth:有人发好人卡大绝了!!!! 12/22 16:28