Topic | HTML | Javascript Code | Sample |
---|---|---|---|
Select/option
|
<select id='ex'> <option value='Opt1' selected>Opt1</option> <option value='Opt2'>Opt2</option> <option value='Opt3'>Opt3 </option> <select> <img src="plus-black.png" onclick="addOpt()"> |
function addOpt() { var option=document.getElementById("ex").selectedIndex; alert ("option is: "+ option); } |
|
date field |
<input type='date' id='dueDate' min="2019-10-01" max="2020-12-31"> <img src="calendar-black.png" onclick="addDate()"> |
function addDate() { var Due=document.getElementById("dueDate").value; alert ("option is: "+ Due); } |
|
Dynamically changing color |
<div id='ex2' style='color:Tomato' onclick='changeIt()'>Click ME!<div> |
function changeIt() { str="<div id='ex2' style='color:Blue'>"; str+="I'm Blue now<div>"; document.getElementById("ex2").outerHTML=str; } |
Click ME!
|