diff --git a/index.html b/index.html new file mode 100644 index 000000000..ad08c1035 --- /dev/null +++ b/index.html @@ -0,0 +1,64 @@ + + +
+ + +This is a sample web page with JavaScript functionality.
+ + + + + +Click a button to see JavaScript in action!
+Hello from JavaScript! This message was generated by the external script file.
'; +} + +function changeColor() { + const output = document.getElementById('output'); + const colors = ['#e3f2fd', '#f3e5f5', '#e8f5e8', '#fff3e0', '#fce4ec']; + const randomColor = colors[Math.floor(Math.random() * colors.length)]; + + output.style.backgroundColor = randomColor; + output.innerHTML = 'Background color changed! The new color is: ' + randomColor + '
'; +} + +function showDateTime() { + const output = document.getElementById('output'); + const now = new Date(); + const dateTimeString = now.toLocaleString(); + + output.innerHTML = 'Current date and time: ' + dateTimeString + '
'; +} + +// Add event listener for when the page loads +document.addEventListener('DOMContentLoaded', function() { + console.log('JavaScript file loaded successfully!'); + + // You can add any initialization code here + const container = document.querySelector('.container'); + if (container) { + container.addEventListener('click', function(event) { + if (event.target.classList.contains('button')) { + console.log('Button clicked:', event.target.textContent); + } + }); + } +}); \ No newline at end of file