Implement Dynamic Vertical Bar effects based on jquery, jquery Dynamic Vertical
This article introduces the Bar implemented by jquery, which is often used in data statistics. Next we will share the code and introduce the implementation process in detail.
The Code is as follows:
<Html>
The above code implements the dynamic effect of columnar data. The following describes the implementation process.
1. $ (function (){}),When the document structure is fully loaded, execute the code in the function in the disaster area.
2. var I = 1,Declare a variable and assign an initial value of 1, which will be used later. We will not introduce it here for the time being.
3. $ ('# top'). height (8 ),Set the height of the top element to 8 PX.
4.(('{buttom'{.css ('margintop ', 42 ),Set the top margin of the buttom element to 42px42 + 8 = 50, which is exactly the height of the container element, so that the top element can be located at the top of the container.
5.(('{buttom'{.css ('background', '# d6d6d6 '),Set the background color of the bottom element.
6. interid = setInterval (Showgao, 0 ),Use the timer function to continuously call the Showgao function.
7. function Showgao (){},If this function is not executed once, the top margin and height of the bottom element are set accordingly to achieve the dynamic increase of the top element at the top and the bar.
8. var oldh1_detail ('{buttom'{.css ('margintop '),Obtains the size of the top margin of the buttom element. 9. var h = oldH. substr (0, oldH. indexOf ('px ') to obtain the numerical part of the size value, such as 28 in "28px.
10.20.('{buttom'{.css ('margintop ', h-1 ),Reduce the size of the top margin by one.
11. $ ('# buttom'). height (I ),Set the height of the buttom element.
12. I ++,I value plus 1.
13. if (I = 43) {clearInterval (interid );},If the I value is 43, it means that the buttom height value is 42px, and the sum of the top height is 50px, the timer function is stopped.
The above is the detailed content of this article, hoping to help you learn jquery programming.
Articles you may be interested in:
- JQUERY-based bar chart plug-in
- JQUBAR1.1 jQuery bar chart plug-in released
- Use the jQuery jqPlot plug-in to draw a bar chart
- Create a simple bar chart using jQuery
- JQuery. Highcharts. js
- JQuery uses ajax to implement the Code to vote for a new bar chart without any animation effect