jQuery Tutorial
var str = "welcome to jQuery!"; var str = 'welcome to jQuery!'; var str = "welcome to 'jQuery'!"; var str = 'welcome to "jQuery"!';
<html> <head> <title>The jQuery Example</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type = "text/javascript"> $(document).ready(function(){ var str = "welcome to 'jQuery'!"; document.write(str); }); </script> </head> <body></body> </html>Output:
var intVal = 24; var doubleVal = 34.56; var floatVal = 0.45;
<html> <head> <title>The jQuery Example</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type = "text/javascript"> $(document).ready(function(){ var intVal = 160; document.write("integer value: " + intVal.toString()); }); </script> </head> <body></body> </html>Output:
var boolVal = false; var boolVal = true;
<html> <head> <title>The jQuery Example</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type = "text/javascript"> $(document).ready(function(){ var boolVal = true; if(boolVal) { document.write("Condition is true!"); } else { document.write("Condition is false!"); } }); </script> </head> <body></body> </html>Output:
var student = { name: "student1", mark: 90 };
<html> <head> <title>The jQuery Example</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type = "text/javascript"> $(document).ready(function(){ var student = { name: "student1", mark: 90 }; //Getting object properties document.write("name: " + student.name + "Output:
mark: " + student.mark); //Setting object properties student.name = "student2"; student.mark = 87; document.write("
name: " + student.name + "
mark: " + student.mark); }); </script> </head> <body></body> </html>
var arr = []; var arr1 = ["one", "two", "three"];
<html> <head> <title>The jQuery Example</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type = "text/javascript"> $(document).ready(function(){ var arr = ["one", "two", "three"]; arr.push("four"); arr.push(5); for(var i=0; iOutput:"); } }); </script> </head> <body></body> </html>
jQuery Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page