calling created javascript function in jquery -
i want call created javascript function in jquery. want trigger function when div
'sample' class.i tried append class in click event.
my script function worked when called in javascript. need call in jquery.
$(document).ready(function() { $('#digital-services').click(function() { $('#second-menu').addclass('sample'); }); }); $(window).scroll(function() { var menu = $('.sample'); console.log(menu.length); if (menu.length == 1) { var y = setinterval(counter, 10); //calling in jquery not working } }); var y = setinterval(counter, 10); //working var x = 0; function counter() { if (x < 11) { document.getelementbyid('counter1').innerhtml = x; } if (x < 601) { document.getelementbyid('counter2').innerhtml = x; } if (x < 31) { document.getelementbyid('count3').innerhtml = x; } if (x < 7) { document.getelementbyid('counter4').innerhtml = x; } if (++x == 601) clearinterval(y); console.log('counter log'); }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a id="digital-services" href="#second-menu">digital services</a> <div class="container" id="second-menu"> <div class="col-sm-3 digital-services-content"> <p id="counter1" class="counter1 counting">10</p> </div> <div class="col-sm-3 digital-services-content"> <p id="counter2" class="counting">600</p> </div> <div class="col-sm-3 digital-services-content"> <p id="count3" class="counter3 counting">30</p> </div> <div class="col-sm-3 digital-services-content"> <p id="counter4" class="counter4 counting">6</p> </div> </div>
Comments
Post a Comment