Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Saturday, March 1, 2014

Get Current Date, Month & Year in JavaScript

Get Current Date, Month & Year in JavaScript

Simple JavaScript code to display current date, month and year by getFullYear() method.

<html>
<body>
<p>Click the button to display the date & year.</p>
<button onclick="getYear()">Current Year</button>
<script>
function getYear()
{
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
}
</script>
</body>
</html>

Example:




Copy Code:

Thursday, January 2, 2014

How to add common pages in html using Jquery

How to add common pages in html using Jquery?


Simple example for including common files in HTML. JQuery load() function is used for including common HTML files in multiple pages. An example for this is added here,

<html>
<head>
<title>Include Common Files in HTML</title>
<script src=“http://code.jquery.com/jquery-1.10.2.js”></script>
</head>
<body>
<div id=“header”></div><br />
<div id=“content”>
Main Content
</div><br />
<div id=“footer”></div>
<script>
$(“#header”).load(“header.html”);
$(“#footer”).load(“footer.html”);
</script>
</body>
</html>