Div出现了盲目效果问题jquery

时间:2012-10-06 19:53:39

标签: jquery

我写了一个例程,它将动态创建一个div并覆盖另一个div。我的代码没有错误,但我想做的事情并没有变得完美。我认为我的代码中存在逻辑或css相关的问题。所以我在这里给我的代码请通过,如果可能的话请纠正它。

我的HTML

<div id="box-outer">
    <div id="data-box">
        This is your data.
    </div>
 </div>
 <asp:Button ID="blinddwn" runat="server" Text="BLIND-2-DOWN" />

我的CSS

 #box-outer
    {
        overflow: hidden;
        height: 200px;
        width: 200px;
        margin: 20px;
        padding: 10px;
        background-color:Green;
    }

我的Jquery例程

 $(document).ready(function () {
        jQuery.fn.exists = function () { return this.length > 0; }

        jQuery.fn.blindToggle = function (speed, easing, callback) {
            var oDiv;
            var margin_top = this.outerHeight() + parseInt(this.css('paddingTop')) + parseInt(this.css('paddingBottom'));

            if ($("#BlindBox").exists() == false) {
                var _height = this.outerHeight();
                var _width = this.outerWidth();

                oDiv = $("<div id='BlindBox'></div>");
                oDiv.css("height", _height + 'px');
                oDiv.css("width", _width + 'px');
                oDiv.css("margin-top", ('-' + margin_top + 'px'));
                oDiv.css("padding", "10px");
                oDiv.css("background", "#e459e9");
                oDiv.css("position", "relative");
                oDiv.css("display", "none");
                this.append(oDiv);
            }
            else {
                oDiv = $('#BlindBox');
            }


            if (parseInt(oDiv.css('marginTop')) < 0) {
                oDiv.css('display', 'none');
            }

            return oDiv.animate({ opacity: 'toggle',
                marginTop: parseInt(oDiv.css('marginTop')) < 0 ? 0 : ('-' + margin_top + 'px')
            }, speed, easing, callback);

        };
    });

        $(document).ready(function () {
            $('#blinddwn').click(function () {
                $('#box-outer').blindToggle('slow');
                return false;
            });
        });

如果有人运行代码,那么他/她看到BlindBox div没有正确覆盖我的另一个名为box-outer的div。请看看我的日常工作并告诉我这是什么问题。尽可能纠正它

这里我给了另一个网址链接http://jsfiddle.net/tridip/YdnLd/8/,只需点击这里,您就会看到我正在尝试通过代码完成的效果。我希望通过我的代码做同样的效果。所以请告诉我代码中的问题。感谢

0 个答案:

没有答案
相关问题