Problem with creating a simple jquery slide show - .append() method is too slow!!
Hello,
i have created a simple jquery slideshow on a webpage.
In that webpage i use php and i have a relational db,too.
I use append in order to show the images and
i notice that append is too slow!
I have a div which consists of "href" . Every href is a link to an image.
Also, i use .append()
The code is as follows:
- <html>
- <head><title>SImple Jquery slide show - TEST</title></head>
- <body>
-
- <div class="div_photos">
- //photos are shown here, by using append
- </div>
- <div class="LinksForImages">
- // List of Links of my images
- <a href="photos/img1">1</a>
- <a href="photos/img2">2</a>
- <a href="photos/img3">3</a>
- <a href="photos/img4">4</a>
- <a href="photos/img5">5</a>
- </div>
- <script type="text/javascript" src="jquery.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- $(".LinksForImages a").click(function () {
$(".div_photos img").hide();
var attr_href = $(this).attr('href');
// alert(attr_href);
$(".div_photos").append('<img src="'+attr_href+'" style="border:1px solid yellow"').;
return false; // used for href links
});
- });
- </script>
- </body>
- </html>
The problem is with append, it's too slow!!!
Also, the div "LinksForImages" is being created by using a php function
- <div class="LinksForImages">
- // List of Links of my images
- <a href="photos/img1">1</a>
- <a href="photos/img2">2</a>
- <a href="photos/img3">3</a>
- <a href="photos/img4">4</a>
- <a href="photos/img5">5</a>
- </div>
Is there any better and faster way to use in order to create a simple jquery slide show instead of using .append()??
Cause, .append() appears to be slow and the user can understand that.
Thanks, in advance!