Jquery UI 选项卡 - 选项卡仅对内容有效
非常感谢任何帮助,
我试图仅当 div 中存在内容时才使选项卡处于活动状态(“可点击”)。内容将来自 php sql 查询。
在最简单的形式中,
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Hello</a></li>
<li><a href="#tabs-2">Goodbye</a></li>
</ul>
<div id="tabs-1">
if Query returned result, echo results, tabs-1 active
</div>
<div id="tabs-2">
if Query returned 0 results, nothing to echo tabs-2 inactive
</div>
</div>
我猜活动/非活动部分不必基于查询结果 - div 中的字符数或 div 的大小都可以是我可以用来查看 div 是否为空的指示器。
我对 javascript 知之甚少,所以如果有一个解决方案,您是否可以在与一个小孩交谈时解释它......
提前非常感谢,我希望我的问题足够清楚。
any help gratefully received
I am trying to get a tab to be active ("clickable") only if there is content present within the div. The content will come from a php sql query.
In it's simplest form
<script>
$(function() {
$( "#tabs" ).tabs();
});
</script>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Hello</a></li>
<li><a href="#tabs-2">Goodbye</a></li>
</ul>
<div id="tabs-1">
if Query returned result, echo results, tabs-1 active
</div>
<div id="tabs-2">
if Query returned 0 results, nothing to echo tabs-2 inactive
</div>
</div>
I guess the active/inactive part does not have to be based on the query result - number of characters in the div or size of div may both be indicators I could use to see if the div is empty.
I know very little about javascript so if there is a solution out there is it possible you could explain it as you were speaking to a small child...
Many thanks in advance and I hope my question is clear enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
select
拦截选项卡更改事件,如下所示:You can intercept the tab change event using
select
, something like: