Jquery变量不适用于Click事件

时间:2012-01-05 18:23:08

标签: jquery variables object

为什么这不起作用?!!

$(document).ready(function(){

    var chooseSection = $("#chooseSection");
    var diabetesSection = $(".diabetesSection");

    chooseSection.live('click', function() {
        diabetesSection.css('display','block');
        setTimeout(function() {
            diabetesSection.addClass('fullfadeIn');
        },20);
        console.log("clicked")
    });

    });

HTML

<div class="row orders-header">
    <div id="orders-back" class="columns">
        <div id="orderCol" class="columns">
            <div class="theBackBtn">Active Orders</div>
        </div>
    </div>
    <div id="chooseSection" class="columns">
        <div class="order-header-btn">
            Choose Section...
        </div>
        <div id="popUp" class="diabetesSection" style="display: none; ">
                        <div class="pop-arrow"></div>
                        <div class="diabetesSection-options">
                            <ul>
                                <li>Suggested</li>
                                <li>Labs</li>
                                <li>Medications</li>
                                <li>Other Tests</li>
                                <li>Referrals</li>
                                <li>Office Procedures</li>
                                <li>Sets</li>
                            </ul>
                        </div>
                    </div>
    </div>
    <div class="columns" style="width:50%; float:right;">
        <input class="general-searchbar orders-search" placeholder="Search Orders...">
    </div>
 </div>

2 个答案:

答案 0 :(得分:1)

我试过,效果很好......

确保你有两个元素(id为“chooseSection”的元素和其他类为'diabetesSection'的元素)

或者这是否适用于任何浏览器?

答案 1 :(得分:1)

什么不起作用?

http://jsfiddle.net/rawsmell/RU2H8/2/

它会显示并添加class,因此div最终会显示diabetesSection fullfadeIn。它应该如何运作?