Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jquery slide to left

Posted on 2011-03-10
7
Medium Priority
?
761 Views
Last Modified: 2012-05-11
Hi

i want to create an effect whee,rby i have content and when a button is clicked or hovered over the hidden content on the right is revealed because it slides to the left

So, in theory like a fruit machine wheel but horizontal instead of vertical.

Can this be done with jquery?

Thanks
0
Comment
Question by:coolispaul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 5

Expert Comment

by:soujanya_g
ID: 35095438
Hi


Check this link


http://www.1stwebdesigner.com/css/36-eye-catching-jquery-navigation-menus/

where  will have multiple sliding
But I think the opt one is

http://www.ndoherty.biz/demos/coda-slider/1.1.1/#4
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35096034
a simple example, hover would be .hover()

<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <style type="text/css">
            html,body {

                position:absolute;
            }


            #a {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
                height:100px;
                width:100px;
                background-color:blue;
                z-index: 10;
            }
            #b {
                display:block;
                position: absolute;
                left: 0;
                top: 0;
                height:100px;
                width:100px;
                background-color:red;


            }
            input{
                position: absolute;
                left: 0;
                top:130px;
            }


        </style>

        <script type="text/javascript" src="preload.js"></script>

        <script type='text/javascript'>
            $(function(){
                $("input[type='button']").click(function() {
                    $('#a').animate({left: parseInt($('#a').css('left'),10) == 0 ? -$('#a').outerWidth():0
                    });
                });
            });
        </script>
    </head>
    <body>
        <div id="a"></div>
        <div id="b">Hi</div>
        <input type="button" value="click here"/>
    </body>
</html>

Open in new window

0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35096114
bit of code for hover/mouse over
              $("#a,#b").mouseover(function() {
                    $('#a').animate({left: parseInt($('#a').css('left'),10) == 0 ? -$('#a').outerWidth():0
                    });
                })

Open in new window

0
Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

 

Author Comment

by:coolispaul
ID: 35096160
can this example be expanded to have unlimited slides rather than 2?

Cheers
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35108439
Had a play and come up with this:
<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <style type="text/css">
            html,body {

            }
            .area{
                position:relative;
                height:100px;
                margin-top: 50px;
                width:100px;


            }
            .a {
                display:block;
                position: absolute;               
                height:100px;
                width:100px;
                background-color:blue;
                z-index: 10;
                left:0;
            }
            .b {
                display:block;
                position: absolute;                
                height:105px;
                width:100px;

                background-color:red;


            }
            input{
                position: absolute;
                left: 0;
                top:130px;
            }


        </style>

        <script type="text/javascript" src="preload.js"></script>

        <script type='text/javascript'>
            $(function(){
                $(".area").each(function(){
                    $(this).mouseenter(function() {
                        var tomove = $(this).children(".a");
                        var outer = tomove.outerWidth();
                        var leftside= tomove.css('left');
                        tomove.stop().animate({left: parseInt(leftside,10) == 0 ? -outer:0
                        });
                    });
                });
                
            });
        </script>
    </head>
    <body>
        <div class ="area">
            <div class="a">Whats the first day of the week</div>
            <div class="b">Monday</div>

        </div>
        <div class ="area">
            <div class="a">How many 2's in 20</div>
            <div class="b">10</div>

        </div>
        <div class ="area">
            <div class="a"></div>
            <div class="b">Hi</div>

        </div>
        <!--        <input type="button" value="click here"/>-->
    </body>
</html>

Open in new window

0
 

Author Comment

by:coolispaul
ID: 35108898
Hi Thanks although i meant the number of slides rather than instances of a slide

So at the moment you have a blue slide then a red slide on hover. If i wanted a third slide shown when hovering on the red slide how can that be achieved?
0
 
LVL 13

Accepted Solution

by:
darren-w- earned 2000 total points
ID: 35109197
Here you go, its not 100%, a bit more work is required to get them to slide back in order (if required), but in answer to the question jquery can do this :)

<html>
    <head>
        <title>test</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <style type="text/css">
            html,body {

            }
            .area{
                position:relative;
                height:100px;
                margin-top: 50px;
                width:100px;


            }
            .a {
                display:block;
                position: absolute;               
                height:120px;
                width:100px;
                background-color:blue;
                z-index: 10;
                left:0;
            }
            .b {
                display:block;
                position: absolute;                
                height:110px;
                width:100px;
                z-index: 5;

                background-color:red;


            }
                        .c {
                display:block;
                position: absolute;
                height:100px;
                width:100px;

                background-color:yellow;


            }
            input{
                position: absolute;
                left: 0;
                top:130px;
            }


        </style>

        <script type="text/javascript" src="preload.js"></script>

        <script type='text/javascript'>
            $(function(){
                $('.a,.b').each(function(){
                    $(this).mouseenter(function() {
                        var tomove = $(this)
                        var outer = tomove.outerWidth();
                        var leftside= tomove.css('left');
                        tomove.stop().animate({left: parseInt(leftside,10) == 0 ? -outer:0
                        });
                    });
                });
            });
        </script>
    </head>
    <body>
        <div class ="area">
            <div class="a">Whats the first day of the week</div>
            <div class="b">Monday</div>
            <div class="c">Monday</div>

        </div>
        <div class ="area">
            <div class="a">How many 2's in 20</div>
            <div class="b">10</div>
            <div class="c">ten</div>

        </div>
        <div class ="area">
            <div class="a">a</div>
            <div class="b">b</div>
             <div class="c">c</div>

        </div>
        <!--        <input type="button" value="click here"/>-->
    </body>
</html>

Open in new window

0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question