In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how jquery can click and add a number. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Method: 1, create a button button and bind the click click event, specify an event handler function; 2, in the event handler function, use the "$(digital object). Val ();" statement to get the value; 3, use the "$(digital object). Val (numeric value * 1q1);" statement to add 1 to the obtained value.
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
The method of adding a number to a click in jquery
1, create a new html file, named test.html, used to explain how to use jquery to achieve mouse click plus sign text box number plus 1. Create a text box using the input tag and set its default value to 1. Set the id of the input tag to myput, which is mainly used to obtain the input object through this id.
Within the test.html file, use the button tag to create a button with the name "+" plus sign. Bind the onclick click event to the button button, and execute the addone () function when the button is clicked.
2, in the js tag, create the addone () function, within the function, get the input object through id (myput), use the val () method to obtain its value, then add 1 to the obtained value, and then re-assign the value to input through the val () method, so as to realize the operation of adding 1 to the number in the text box.
Open the test.html file in the browser and click the plus sign to see the effect.
After clicking the button
Summary:
1. Create a test.html file.
2. In the file, use the input tag to create a text box, set the id of the input tag to myput, and create a button button to trigger the execution of the js function.
3, in the js tag, create a function, within the function, get the input object through id (myput), use the val () method to obtain its value, then add 1 to the obtained value, and then re-assign the value to input through the val () method, so as to realize the operation of adding 1 to the number in the text box.
Matters needing attention
The res value, multiplied by 1, is used primarily to convert strings to numeric types.
Thank you for reading! This is the end of the article on "how to click and add a number in jquery". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.