user2232273
user2232273

Reputation: 4964

How to open the gallery when the user click on the button

Always when i open my page, the gallery open every time automatically. but i only want that opens if the user click on the button. how can i fixed this problem?

<a onClick="$('.fixed-bar').toggle('slow');"

<div class="container demo-3">
                 <div class="main">
                   <div class="fixed-bar">

                    <ul id="carousel" class="elastislide-list">
                        <li><a href="#"><img src="elastislide/small/1.jpg" alt="image01" /></a></li>
                        <li><a href="#"><img src="elastislide/small/2.jpg" alt="image02" /></a></li>
                        <li><a href="#"><img src="elastislide/small/3.jpg" alt="image03" /></a></li>

<script type="text/javascript">

            $( '#carousel' ).elastislide( {
                minItems : 2
            } );

        </script>

Upvotes: 0

Views: 393

Answers (1)

Rahul
Rahul

Reputation: 5774

If I assume fixed-bar div needs to be hidden on page load

make <div class="fixed-bar" style="display:none">

Instead of <a onClick="$('.fixed-bar').toggle('slow');"> stuff use

<a id="gallery-toggle" href="">Toggle Gallary</a>

and inside <script></script>

write this code

$('#gallery-toggle').click(function()
{
    $('.fixed-bar').toggle('slow');
}); 

Much better approach.. :-)

OR in your code, just add display:none in style attribute.. That will solve the issue.

Let me know how that works,

Regards,

Rahul

Upvotes: 1

Related Questions