Guest User

Untitled

a guest
Apr 28th, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. $(function() {    
  3.     $(".addcart").click(function() {
  4.    
  5.        var intId = $(".view").size() + 1;
  6.        var fieldId= "field" +intId;
  7.        
  8.        var img = $(this).parent().children('img').attr('src');
  9.        
  10.        $('.slideshow-slides .slide').append('<div class="view" id="'+fieldId+'"><img src="'+img+'" /><div class="mask"><h2>' +"Title"+'</h2><button class="deleteimg">'+"DELETE"+'</button></div></div>');
  11.  
  12.        $(".view").each(function (intId) {
  13.             $(this).css({ left: 240 * intId + 'px' });
  14.         });    
  15.        
  16.        $(".deleteimg").click(function() {
  17.             $(this).parent().parent().remove();        
  18.             var wrappers = $(".view");
  19.             if (wrappers.length >= 1) {
  20.                 var newId = 1;
  21.                 wrappers.each(function(){
  22.                     renewId = "field" + newId;
  23.                     $(this).attr("id",renewId);
  24.                     var newPosition = newId-1;
  25.                     $(this).css({ left: 240 * newPosition + 'px' });
  26.                     newId++;                   
  27.                 });        
  28.             }
  29.         });
  30.     });        
  31. });
  32.  
  33. </script>
Advertisement
Add Comment
Please, Sign In to add comment