JavaScript

JavaScript

Tuesday 3 March 2015

Javascript Code: Display Date

Today I am going to explain very simple code that displays current date by clicking a button.
For someone who starts his adventure with Javascript it might sound complicated , but don't worry it is much simpler than it looks like.
To write that kind of code user must be familiar with usage of if else statement.
In JavaScript we have the following conditional statements:
  • We use if to specify a block of code to be executed, if a specified condition is true
  • Use else to specify a block of code to be executed, if the same condition is false
  • Use else if to specify a new condition to test, if the first condition is false 

To write Display Date code we need to open Notepad++ and write following code:

This code opens html website on which we can add interactive content.



This Javascript code is based on IF ELSE statement which check todays date and returns date assigned to number.

 After Clicking button" TRY IT " The Date in new paragraph will be displayed.

No comments:

Post a Comment