javascript - Slider with setTimeout - 'removeClass is not a function error' -
so asked similar question earlier today, i'm trying upgrade in code had. i'm trying create slider settimeout function, keep getting removeclass not function error
on jquery
object. here codepen code
once again in advance.
index.html
<div class=container> <img class='isactive' src="http://placehold.it/350x150"> <img class='ishidden' src="http://placehold.it/350x150"> <img class='ishidden' src="http://placehold.it/350x150"> <img class='ishidden'src="http://placehold.it/350x150"> </div>
index.scss
html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } body { background: black; } .container { display: inline; //border: 1px solid white; } .slide { } .isactive { visibility: visible; } .ishidden { visibility: hidden; }
index.js
$(function() { var timer; var $allimgitems = $('img'); var $items = $('.container').find($allimgitems); (let = 0; < $items.length; i++) { var $item = $items[i]; $item.removeclass('ishidden').addclass('isactive') /*$item.removeclass('ishidden').addclass('isactive).settimeout(function() { $( ).animate( { scrollleft: 200 + 'px' } ), '500', 'swing', function() { console.log('animation completed') } }) */ console.log(`we @ item: ${$item}`); } })
check out how changed js function bit. seems work fine now.
$(function() { var timer; var $items = $('img', '.container'); (let = 0; < $items.length; i++) { var item = $items[i]; $(item).removeclass('ishidden').addclass('isactive'); console.log(`we @ item: ${item}`); } })
html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } body { background: black; } .container { display: inline; //border: 1px solid white; } .slide { } .isactive { visibility: visible; } .ishidden { visibility: hidden; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class=container> <img class='isactive' src="http://placehold.it/350x150"> <img class='ishidden' src="http://placehold.it/350x150"> <img class='ishidden' src="http://placehold.it/350x150"> <img class='ishidden'src="http://placehold.it/350x150"> </div>
Comments
Post a Comment