This article describes the JS custom horizontal scrolling font plugin. Share it for your reference, as follows:
<script type="text/javascript"> $(function(){ var setting = { content : " @@@@@Floating Text#### ", overStop : true, width:"100px", targetId:"huangbiao", //The callback function after display onAfterShow : function(obj){ = "20px"; // alert("dddd"); //Reset after modifying the configuration file// (); //Delete dynamically added content// (); } }; var ooo = new fontMove(setting); //Reset// = "20px;" // (); }); /* Principle description: 1. The top parent div is a scrollbar 2. The width of the secondary DIV (child div of top parent div) is 8000% 3. There are two third-level sub-divs, namely div1 (leftmost) and div2 (second left) and node content is exactly the same, both floating towards left. 4. Set a timer and scroll bar of top div to the left by 1px 5. Once the length of the top div scroll bar is greater than or equal to the distance of the scroll bar of div2, make the distance of the top div scroll bar be 0. */ function fontMove(userSettingObj){ var that = this; //Use the timestamp as the id value var timestamp = new Date().getTime(); = { //Scrolling text content content : "Floating Text", //The width of the scroll bar display width:"200px", //Execute every 30 milliseconds speed : 30, //Whether the mouse suspension stops, true is true, false is non-stop, default is true overStop : true, //The ID value of the scroll bar objId : timestamp, // If the target position of the space is "", it is placed at the end of the body tag by default targetId : "", onAfterShow:function(){ } }; //Get the user's configuration file = $.extend(,userSettingObj); //Check the parameters of the configuration file = function(){ } //Extension plug-in = function(myfun){ if(typeof myfun == "function"){ //this stands for callback, so parent needs to be used (that); } } = function(){ $("#"+).remove(); } = function(){ //All methods to get configuration files are to use var domStr = '<div style="overflow:hidden;width:'++'">'+ '<div style="width:8000%;">'+ '<div style="float:left;">'++ '</div>'+ '<div style="float:left;">'++'</div>'+ '</div>'+ '</div>'+ '</div>'; //Judge whether the content is stored in the following places if(""==){ $("body").append(domStr); }else{ $("#"+).html(domStr); } //Content container div var thatDiv = (); //The first child div on the left var sonDiv1 = ( + '_div1'); //The second child div on the left var sonDiv2 = ( + '_div2'); = function(){ //Use timer to change the value// (" : " + ); // // The value remains unchanged// (" : " + ); // // The value is always 0, because it has no scrollbar// (" : " + ); // // The value remains unchanged// (" : " + ); // // The value is always 0 because it has no scrollbar// (" : " + ); //The distance of the top div scroll bar is greater than the horizontal distance of the first sub-div, that is, whether it is greater than the actual distance of the content if( - >= 0){ //The length of the scroll bar is cleared again by 0, which is equivalent to displaying from the first div again, and then scrolling to the left = - ; } else{ ++; } } var myvar=setInterval(,); //The mouse is suspended, whether to stop moving if(){ =function(){clearInterval(myvar);} =function (){myvar=setInterval(Marquee,30);} } if(typeof == "function"){ (that,that); } } // Complete initialization (); //Return the method itself, so that all parameters of this can be obtained return this; } </script>
For more information about JavaScript, readers who are interested in reading this site's special topic:Summary of JavaScript switching effects and techniques》、《Summary of JavaScript search algorithm skills》、《Summary of JavaScript animation special effects and techniques》、《Summary of JavaScript Errors and Debugging Skills》、《Summary of JavaScript data structure and algorithm techniques》、《JavaScript traversal algorithm and skills summary"and"Summary of JavaScript mathematical operations usage》
I hope this article will be helpful to everyone's JavaScript programming.