Voting system display results plug-in based on jQuery_jquery
WBOYOriginal
2016-05-16 18:03:311390browse
First, let’s take a look at the running effect, as shown in Figure 1.
Steps to use this plug-in 1. Import the css file First, import the css style file 'votecss.css' into the page, which is necessary for the normal display of voting results. Less. The specific code is as follows:
2. The source file that introduces jQuery is the source file The plug-in is based on jQuery, so the specific code required to introduce the jQuery plug-in is as follows:
3. Introducing the voting plug-in Introducing the self-developed voting plug-in "Studyplay_vote.js", the specific code is as follows:
4. Page call First add a div element with ID 'z' to the page and write JavaScript code to display the voting results. The specific code is as follows:
The effect of running this code is shown in Figure 1. Note: This plug-in has two parameters 1. Options is a required plug-in. It is an object data. The specific form is as follows. [{},{}...{}]The number of this array is the number of voting options. If there are ten voting options, this array must be 10; {} is json data, there are three items in total . "name" represents the name of the voting option; "data" represents the number of votes for this option; "color" represents the column color of this option. 2. The totle optional parameter can be omitted. Indicates the total number of votes cast, mainly used for calculating percentages for multiple choice votes.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn