【发布时间】:2013-02-18 19:29:37
【问题描述】:
我对 jquery 有点陌生,所以对如何选择父选项卡或只是在当前手风琴上添加效果感到困惑。我在 php 条件下的脚本中编写的任何代码都不会对 .ui-widget-header 的 css 进行任何可见的更改,这很可能是因为我没有选择父元素本身。
让我给我的代码必要的sn-p
<div id="tabs">
<ul>
<li><a href="#tabs-1">Tab 1</a></li>
<li><a href="#tabs-2">Tab 2</a></li>
<li><a href="#tabs-3">Tab 3</a></li>
</ul>
<div id="tabs-1">
<div id="accordion">
<div> Some content </div>
<div>
<?php
//Perform some query
if (mysqli_num_rows($query)==0)
//Make background of current accordion, and parent tab red. Add jquery script here
echo "<script type='text/javascript'> </script>";//No clue what should be within this script, hence blank...
//Probably something like $("accordion").parent("#tabs").css( background-color: red;background-image: none;)
//OR $(this).parents('div#tabs').css( background-color: red;background-image: none;)
?>
</div>
<div>
2nd accordion. There should be no effect here.
</div>
</div>
.....
修改后的剪辑可在 - jsfiddle.net/buKLE/8 上找到...目前只有标签和手风琴。如果可能,尝试更改 tab1 的 css,假设手风琴第 2 节有错误。 是否甚至可以改变那只手风琴的颜色,因为所有的手风琴都在这里绑定在一起......
【问题讨论】:
-
我在您的标签中看不到任何 javascript 代码?
-
编辑:您能向我们展示您尝试过的一些代码吗?
-
我不知道应该如何选择该父选项卡,然后更改它的 css 属性。很确定这都是错误的,但只是编辑了我认为的样子。
-
不要害怕在您的问题中发布该代码,这对回答您的问题很有帮助。
标签: javascript jquery jquery-ui