English 中文(简体)
如何找到一个班子,并采用一种带 j的风格?
原标题:how to find a class and apply a style with jquery?

i have this example in jsfiddle of a accordion only made with css3, no js.

<>光>:

<div class="ac-container">
    <div>
        <input id="ac-1" name="accordion-1" type="radio" checked />
        <label for="ac-1">About us</label>
        <article class="ac-small">
            <p id="test_small">test</p> <-- this tag will come from php
        </article>
    </div>
    <div>
        <input id="ac-2" name="accordion-1" type="radio" />
        <label for="ac-2">How we work</label>
        <article class="ac-medium">
            <p id="test_medium">test</p>
        </article>
    </div>
</div>​

http://www.ohchr.org。

.ac-container input:checked ~ article.ac-small{
    height: 140px;
}
.ac-container input:checked ~ article.ac-medium{
    height: 180px;
}
.ac-container input:checked ~ article.ac-large{
   /* height: 240px;*/
}

问题一是,高点已经确定,一是增加原样,一是不能确定有多少内容需要具有动态的高度。

the php will be loading the p tag so i can find the height like this:

var v = $("#test_small").height();

// add the height to the .ac-small
$( .ac-container input:checked article.ac-small ).css("height", v+ px );

问题一是,胜数适用于选任人,即认为选任人<代码>(......ac-container content:checked article.ac-small >是错的。

最佳回答

审判

$( .ac-container input:checked ).parent( div ).children( article.ac-small ).css("height", v+ px );
问题回答

你的选择是错误的。 请允许我向您解释一下这些选择者 f:

$( .ac-container input:checked article.ac-small )

它将选择<代码><article>s和-small,这些元素存在于一个要素<代码>ac-container内。

Well you can t have element inside of an input...

在<代码>cs 您写道:

.ac-container input:checked ~ article.ac-small{
    height: 140px;
}

First:
You have to change the id to a class

var v = $(".ac-small").height();

Second:
If you want to get the sibling of your input you have to do it:
Get the checked input inside the container, when found get it article sibling and then set the css.

$( .ac-container ).find( input:checked ).siblings( article ).css("height", v+ px );

var v = $("#ac-small").height();

But you don t have any element with an id of "ac-small".





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签