Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Toogle使用jquery最大化宽度和高度div_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript Toogle使用jquery最大化宽度和高度div

Javascript Toogle使用jquery最大化宽度和高度div,javascript,jquery,html,css,Javascript,Jquery,Html,Css,您好,我想使用jquery最大化和最小化div。 我使用remove和add类方法,当它最大化和最小化时。 但当它已经最大化时,它不会最小化 这里是我的jquery代码: $('.readmore').click(function (event) { event.preventDefault(); $("#ry-new-content-3").animate({ width : "+=460"

您好,我想使用jquery最大化和最小化
div
。 我使用remove和add类方法,当它最大化和最小化时。 但当它已经最大化时,它不会最小化

这里是我的jquery代码:

$('.readmore').click(function (event) {
            event.preventDefault();
            $("#ry-new-content-3").animate({
                width : "+=460"
            },1000,function(){
                $('.more-content').slideDown('slow', function(){

                });
            });
            $(this).text($(this).text() == 'Read Less' ? 'Read More' : 'Read Less');

            if($(this).attr('class') == 'readmore') {
                $(this).removeClass();
                $(this).addClass('readless');
            }

         });

         $('.readless').click(function (event) {
            event.preventDefault();
            $('.more-content').slideUp('slow', function(){
                $("#ry-new-content-3").animate({
                    width : "-=460"
                },1000,function(){

                });
            });

         });
这是我的HTML代码:

<div id="ry-new-content-3">
        <div class="scrollable-area-page">
            <div class="summary-content">
                <p>
                    The original Master piece was designed by the now famous JMP design group, a California based golf Design Company that has also designed the renowned Rainbow Hills Club & Royal Jakarta courses both located in Jakarta, along with over 70 international standard courses worldwide.
                    Overall Royal Sumatra could easily be rated as one of the most challenging and interesting layouts in all of Indonesia. To pinpoint a special feature of the Royal Sumatra layout is to mention many unique and eye pleasing holes that are spread out amongst the private Modern living cluster style housing estates and still natural forest land.
                </p>
            </div>
            <div class="more-content" style="display:none;">
                <p>
                    One of the concepts in the design was to spread the 18 holes out throughout the 254 hectare estate to not only allow privacy & safety for golfers but add more beautiful golf course views for home owners. Combined with the tropically landscape & buzzing wildlife in our environment including breath taking crystal clear morning views of famous Bukit Barisan & Brestagi Mountains, Royal Sumatra Golf and Country Club provides the strategic test & beautiful environment that every golfer wants and few golf clubs can offer.  
                    A variety of unique features await the avid golfer. Strategy is required at all times. Fairways are generous in size to accommodate the beginner, however undulating and strategically located white sand bunkers, creeks and large lakes add a stern test for the avid golfer to say the least Likely the most challenging feature of this championship layout are the multi tiered and  sloped putting greens which consistently run at fast speeds, to be fair these are arguably the most challenging greens in all of South East Asia. 
                </p>

                <p>
                    A fleet of new Club Car Buggies and 140+ uniformed female caddies complete the golfers every need and with prices all inclusive approximately USD $70 on weekends and USD $55 on weekdays ( Golf, Caddy, Buggy) Royal Sumatra is well worth it for the Golf traveler looking to truly test his golf game without damaging the bank balance. 
                </p>
            </div>
        </div>
        <div class="readmore">
            Read More
        </div>
    </div>


最初的杰作由现在著名的JMP设计集团设计,这是一家总部位于加利福尼亚的高尔夫设计公司,该公司还设计了位于雅加达的著名彩虹山俱乐部和雅加达皇家球场,以及全球70多个国际标准球场。
整个皇家苏门答腊岛很容易被评为印尼最具挑战性和最有趣的布局之一。要准确指出苏门答腊皇家布局的一个特点,就要提到许多独特且令人赏心悦目的孔洞,这些孔洞分布在私人现代居住集群式住宅区和天然林地之间。

设计中的一个概念是将18个洞分布在254公顷的庄园内,不仅为高尔夫球手提供隐私和安全,而且为业主提供更美丽的高尔夫球场景观。结合我们环境中的热带景观和嗡嗡作响的野生动物,包括著名的Bukit Barisan和Brestagi山脉令人叹为观止的水晶般清晰的晨景,皇家苏门答腊高尔夫和乡村俱乐部提供了每个高尔夫球手想要的战略测试和美丽环境,很少有高尔夫俱乐部能够提供。 各种独特的功能等待着这位狂热的高尔夫球手。任何时候都需要战略。球道的尺寸非常大,可以容纳初学者,但是起伏不平,位置战略性的白色沙坑,小溪和大湖对这位狂热的高尔夫球手来说是一个严峻的考验。他说,这项锦标赛布局中最具挑战性的特点很可能是多层和倾斜的推杆果岭,这些果岭一直以极快的速度运行,公平地说,这些果岭可以说是整个东南亚最具挑战性的果岭。

一队新的俱乐部用车和140多名穿制服的女球童满足了高尔夫球手的各种需求,价格包括周末约70美元,平日约55美元(高尔夫、球童、童车)。对于希望在不损害银行余额的情况下真正测试高尔夫球技的高尔夫旅行者来说,皇家苏门答腊是值得的。

阅读更多
谢谢。

你试过了吗?我已经尝试过很多次了,作为个人观点,类交换是不值得的,所以我结束了使用切换或if-statement。例如:

maximized = 500px
if($(".target").height() != maxmized){
   // maximize it
} else {
   // minimize it
}

另外,在不知道它的外观或运行情况的情况下,您可能需要考虑动画时间,如果您单击的速度太快或太慢,操作可能无法启动,因此使用回调将很好。

如果您在Read*上单击两次,它将变回readmore,但div类将保持为readless。在那之后,它将永远保持无读状态。而且似乎你必须触发一个事件,你的类被改变了。参见和类似的Qs