html - Javascript Callback function malfunction -
i trying implement anonymous callback function. code here wrote janky know.
typing intro span, activates .typed
animation given parameters. need activate, , isn't, last function remove 2 elements id there. can't figure out how.
<!-- executes intro typing text --> <script> document.getelementbyid('intro-button').onclick = function() { $(function() { $("#typing-intro").typed({ strings: [" initseg = def_initseg</br> sysseg"], typespeed: 0, backdelay: 20, loop: false, loopcount: false, }, function (){ document.getelementbyid("intro-section").remove(); document.getelementbyid("typing-intro").remove(); }); }); } ///script </script>
as minusfour points out, typed animation function doesn't take callback function final parameter. instead "callback" function passed through options
beyond question, there's lot can clean code. since you're using jquery already, can clean event handler. instead of document.getelementbyid('intro-button').onclick = function() { ... }
can have $('#intro-button').click(function() { ... });
. if placing <script>
in <head>
, want wrap entire thing in in $(function() { ... })
, not have in stuck in middle of code.
finally, since you're using jquery everywhere else, instead of document.getelementbyid("intro-section").remove(); have $('#intro-section').remove().
so this:
$(function() { $('#intro-button').click(function() { $("#typing-intro").typed({ strings: [" initseg = def_initseg</br> sysseg"], typespeed: 0, backdelay: 20, loop: false, loopcount: false, callback: function (){ $("#intro-section").remove(); $("#typing-intro").remove(); } }); }) })
Comments
Post a Comment