مرجع تخصصی برنامه نویسان

انجمن تخصصی برنامه نویسان فارسی زبان

کاربر سایت

arezoo.fg

عضویت از 1394/08/11

animate()

  • پنجشنبه 6 آبان 1395
  • 22:02
تشکر میکنم

سلام به همه!

یه سوال!

چطور می تونم از animate() مثل toggle  استفاده کنم؟

میخوام با هر بار کلیک روی دکمه هام div هایی که مشخص کردم نشون بده

        .box{
            width:200px;
            height:600px;
            position:relative;
            border:1px solid #000000;
            background:#272626;
                     overflow:hidden;
        }
        .child{
            box-sizing:border-box;
            width:200px;
            height:600px;
            position:absolute;
            background:#808080;
       margin-left: 205px;
        }

/////////////////////////////////////////////////////

    <button type="button" id="one">salam!</button>
    <button type="button" id="two">bye!</button>
    <div class="box">
        <div class="child" id="childone"><span>salaaaaaaaam</span></div>
        <div class="child" id="childtwo"><span>babyyyyyyyyyyye</span></div>
      
    </div>

///////////////////////////////////////////////////////////////////

        $('#two').click(function () {
            $('#childtwo').animate({
                marginLeft: "0px"
            }, 500);

        });
        $('#one').click(function () {
            $('#childone').animate({
                marginLeft: "0px"
            }, 500);

        });

 

پاسخ های این پرسش

تعداد پاسخ ها : 2 پاسخ
کاربر سایت

kaveh.norozi

عضویت از 1394/11/30

  • جمعه 7 آبان 1395
  • 09:54
$('.login').toggle(
    function(){
        $('#one').animate({
            height: "150",
            padding:"20px 0",
            backgroundColor:'#000000',
            opacity:.8
        }, 500);
        $('#otherdiv').animate({
            //otherdiv properties here
        }, 500);
    },
    function(){
        $('#one').animate({
            height: "0",
            padding:"0px 0",
            opacity:.2
        }, 500);
        $('#otherdiv').animate({
            //otherdiv properties here
        }, 500);
});

توضیحات تکمیل تر اینجا

کاربر سایت

arezoo.fg

عضویت از 1394/08/11

  • جمعه 7 آبان 1395
  • 22:41
Toggle برای jquery با ورژن 1 هستش و توی ورژن 2و3 کار نمیکنه
کاربرانی که از این پست تشکر کرده اند

هیچ کاربری تا کنون از این پست تشکر نکرده است

اگر نیاز به یک مشاور در زمینه طراحی سایت ، برنامه نویسی و بازاریابی الکترونیکی دارید

با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)