简体   繁体   English

单击下拉按钮时可以缩小区域的任何选项

[英]any option to make a area shrink when a drop down button is clicked

I am working on jquery and javascript. 我正在研究jquery和javascript。 I am using a drop down button which will be there on top right corner of the container. 我正在使用一个下拉按钮,该按钮将位于容器的右上角。

So, is there any option to make a container shrink or move to left whenever the drop down button drops down when clicked. 因此,当单击下拉按钮时,是否有任何选项可以使容器缩小或向左移动。 and the same vice-verse. 和同样的副词。

I too have a fiddle which has one the container which slides from left to right and reversal. 我也有一个小提琴 ,里面有一个可以从左向右滑动并反转的容器。 but i am looking for a solution which makes the container to shrinks or moves to left whenever the drop down button is clicked. 但我正在寻找一种解决方案,使该容器在单击下拉按钮时会收缩或向左移动。 here is the fiddle for it. 这是它的小提琴。

CODE: 码:

      $('#sidebar').click(function(){
      $(this).animate({width:'100px'},{bottom : 100px}, 400);
      $('#steam').animate({bottom : 100px},{width:'500px'}, 400);

      });
        $('#steam').click(function(){
      $(this).animate({width:'100px'},{bottom : 100px}, 400);
      $('#sidebar').animate({width:'500px'},{bottom : 100px}, 400);
       });

try the below solution in js fiddle link. 请尝试以下js小提琴链接中的解决方案。 http://jsfiddle.net/3DpfJ/50/ http://jsfiddle.net/3DpfJ/50/

  [1]: http://jsfiddle.net/3DpfJ/50/

http://jsfiddle.net/33rHZ/1/ http://jsfiddle.net/33rHZ/1/

This fiddle uses the .change event & I have commented out the check for if expanded , as I don't think you need it. 这个小提琴使用.change事件,我已经注释了检查if expanded ,因为我认为您不需要它。 But if you do, simply remove my comments and it should work fine. 但是,如果您这样做,只需删除我的评论即可,它应该可以正常工作。

In summary: 综上所述:

$(function()
  {
      $('#sidebar').change(function(){
          {
             $('#sidebar').animate({width:'69%'}, 400);
             $('#steam').animate({width:'29%'}, 400);
             $('#sidebar').animate({width:'29%'}, 400);
             $('#steam').animate({width:'69%'}, 400);
          }    
      });
  });

Very tidy. 很干净

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当点击它之外的任何区域时,如何使用javascript / jquery隐藏此下拉菜单? - How do I hide this drop down menu using javascript/jquery when any area outside of it is clicked? 单击具有指定功能的按钮时,如何在输出框中的下拉列表中显示选项的值? - How do I display the value of an option on a drop down in an output box when a button with an assigned function is clicked on? 单击下拉选项时如何显示相关数据? - How to display the data related when an option is clicked on drop down? 单击.aspx按钮时.ascx下拉选项值未更改 - .ascx drop down option value not changing when clicking the .aspx button 单击下拉选项时如何使按钮出现? - How to make button appear when dropdown option is clicked? 如何隐藏默认值 <select><option>点击下拉菜单时? - How can I hide default <select> <option> when the drop-down is clicked? jQuery:单击按钮后,选择下拉选项 - Jquery : On clicking the button select drop down option 在javascript中选择下拉选项时在文本区域中加载文本文件 - To load a text file in text area on selection of a drop down option in javascript 单击Bootstrap时如何更改下拉按钮的颜色? - How do I change the drop down button color when clicked Bootstrap? 我需要运行 PHP function 并在进行下拉选择并单击按钮时显示数据 - I need to Run a PHP function and display data when drop down selection is made and button is clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM