How to determine whether there is a remainder in jquery division: Use the if statement, "%" and "==" operators to detect whether two numbers are divisible, that is, whether the remainder of the division is equal to 0. The syntax is: "if (value 1% value 2 == 0)".
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
How to determine whether there is a remainder after jquery division
1. Create a new html file, named test.html, to explain how jquery works Determine whether it is divisible. Use the input tag to create two numeric input boxes, and set their ids to num and num2 respectively. They are mainly used to obtain the input object through this id below. Use the button tag to create a button with the name "Can it be divisible".
In the test.html file, bind the onclick event to the button button. When the button is clicked, the pan() function is executed.
2. In the js tag, create the pan() function. Within the function, obtain the input object through the id value of the input, and use the val() method to obtain the input respectively. Box numbers.
In the pan() function, use the if statement to judge whether num is divided by num2 through "%". If the division is equal to 0, it will prompt "can be divided", otherwise, it will prompt "cannot" divisible".
Open the test.html file in the browser, enter the number in the text box, click the button to see the effect.
Summary:
1. Create a test.html file.
2. In the file, use the input tag to create two numeric input boxes, and create a button button to trigger the execution of the js function to determine the input content.
3. Create a function in the js tag. In the function, obtain the input object through the id value of the input. Use the val() method to obtain the number of the input box respectively, and use "%" to perform integer division
Recommended related video tutorials: jQuery video tutorial
The above is the detailed content of How to determine if division has remainder in jquery. For more information, please follow other related articles on the PHP Chinese website!