HelpMeOutAlways: JavaScript
Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Saturday, December 7, 2019

Variables and Data Type Example In JavaScript (with video tutorial)
December 07, 20190 Comments

Variables and Data Type Example In JavaScrip


A variable is a container to hold information and Data type is the type of a variable i.e int, char, float, etc.

 Source Code

<!DOCTYPE html>
<html>
  <head>
    <meta charset ="utf-8">
    <title>
      change html content
    </title>
    <style>
      .box{
        background-color: green;
        color: white;
        height: 400px;
        width:400px;
          padding: 100px;
          font-size: 40px
             
      }
   
     
    </style>
  </head>
 
  <body>
    <div class="box" id="bluebox">
      <p>
        <p>HelpMeOutAlways is a place for learning JavaScript<p>
       
      </p>
        <script>
          var x=3;
            window.console.log("The value of x is::"+x);
          var y=5;
           var z= x+y;
            window.console.log("The sum of x+y is:"+z);
            window.console.log(typeof(z));
           
            var firstname="ali";
            var lastname="akber"
            var fullname=firstname+ " "+lastname;
            window.console.log("Your name is:"+fullname);
             window.console.log(typeof(fullname));
            var myArray=[1,2,3];
            window.console.log(myArray);
                        window.console.log(typeof(myArray));

        </script>
     
    </div>
    </body>
</html>






Output


javaScript by helpmeoutalways

Video Tutorial

Reading Time:
Changing Style and Html Content In JavaScript (With Video Tutorial)
December 07, 20190 Comments

Source Code

<!DOCTYPE html>
<html>
  <head>
    <meta charset ="utf-8">
    <title>
      change html content
    </title>
    <style>
      .box{
        background-color: green;
        color: white;
        height: 400px;
        width:400px;
          padding: 100px;
          font-size: 20px
      }
   
     
    </style>
  </head>
 
  <body>
    <div class="box" id="bluebox">
      <p>
        <p>HelpMeOutAlways is a place for learning JavaScript<p>
          <button id="button1">Change html content</button>
      </p>
        <script>
         
            document.getElementById("button1").onclick=function(){
               document.getElementById("bluebox").style.width="300px";
                document.getElementById("bluebox").style.fontSize="30px";
                document.getElementById("bluebox").innerHTML="<p>HelpMeOutAlways is a place for learning JavaScript<p>";
                                document.getElementById("bluebox").style.color="white";
                   document.getElementById("bluebox").style.backgroundColor="green";

            }
        </script>
     
    </div>
    </body>
</html>



Output

javaScript by helpmeoutalways

javaScript by helpmeoutalways

Video Tutorial


 


Reading Time:
Changing Text and html Content Using Button in JavaScript (With video tutorial)
December 07, 20190 Comments

 

Changing Text and html Content Using Button in JavaScript 

Here you will get the source code for Changing Text and html Content Using Button in JavaScript.

Source Code

<!DOCTYPE html>
<html>
  <head>
    <meta charset ="utf-8">
    <title>
      change html content
    </title>
    <style>
      .box{
        background-color: #3A5795;
        color: white;
        height: 400px;
        width:400px;
          padding: 100px;
          font-size: 20px
      }
   
     
    </style>
  </head>
 
  <body>
    <div class="box" id="bluebox">
      <p>
        hello! how are you?
          <button id="button1">Change html content</button>
      </p>
        <script>
            document.getElementById("button1").onclick=function(){
               document.getElementById("bluebox").innerHTML="<p>HelpMeOutAlways is a place for learning JavaScript<p>"
            }
        </script>
     
    </div>
    </body>
</html>

Output

javaScript in helpmeoutalways





                                         




           
javaScript in helpmeoutalways




 Video Tutorial

Changing Text and html Content Using Button in JavaScript is very simple.
Enjoy learning JavaScript!

Reading Time:
Button in JavaScript (showing alert message with video tutorial)
December 07, 20190 Comments


Button In JavaScript Example 

JavaScript Button Example Onclick you will get an alert message, you can try it by saving as an .html file and open in any browser.

Source Code

<!DOCTYPE html>
<html>
    <head>
        <title>alert</title>
    </head>
    <body>
        <p>JavaScript</p>
        <button onclick="alert('Hello! You clicked me!')">Click Me!</button>
        <button id="button2">Click Me!</button>
        <script>
       document.getElementById("button2").onclick=function(){
                window.alert("You have just clicked me!");
}
        </script>
    </body>
</html>





Reading Time:

@way2themes