In the following example is the very simplest addition program using jQuery, jQuery is the framework of javascript, jQuery is the plugin created using pure javascript code. The jQuery can easy to do to program.
First we need to create three text boxes one for first number second one for second number and thired for show the sum of two numbers.
Sum of two number jQuery
Creating text box
The text box is the basic element in html, it is very simple to remember and create.
syntax
<input type="text">
The input type having many attributes, the one of the important attribute is id , it is used for accessing the textbox value from javascript/jQuery code.Example
<input type="text" id="txt1">
The id is unique, all html element should have different unique id value.
<input type="text" id="txt1">
<input type="text" id="txt2">
<input type="text" id="txt3">
Creating the button
The button also one of the very important html element, it can do some action while clicking or other action.
syntax
<input type="text" value="Sample button" onclick="call_fun();">
onclick is one of the event, it indicate when the user click on the "Sample button" button the call_fun() will call.
Get the textbox value using javascript
First we need to access the textbox value, so we have a method for get the text box value using javascript
Syntax
document.getElementById("id").value;
Example
var tvalue=document.getElementById("txt1").value;
Empty the textbox value using javascript
We can access and it using elements id, same as the way is clear the textbox value.
Example
document.getElementById("txt1").value="";
Example Program:- (Editor)
Editor is Loading...
Advertisement
0 comments:
Post a Comment