How to run JavaScript function when option selected
select
and option
tag in html, and change event
and if condition
in Javascript <select id="compress" style="padding:3px 5px">
<option value="select" disabled selected>-- select --</option>
<option value="HTML">Compress HTML </option>
<option value="CSS">Compress CSS </option>
<option value="JS">Compress JavaScript </option>
</select>
<script>
var select=document.getElementById("compress");
select.addEventListener("change", function(){
if(select.value == "HTML"){
alert("HTML")
}
if(select.value == "CSS"){
alert("CSS")
}
if(select.value == "JS"){
alert("JS")
}
});
</script>

© 2025 Manajmnt code
Comments
Post a Comment
message