0
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<fieldset><legend>Escolha</legend>
<select>
<optgroup label="Decimal" onclick="f_decimal()">
<option onclick="carro()">Carro</option>
<option onclick="moto()">Moto</option>
</optgroup>
</select>
</fieldset>
<script>
function carro(){
alert("Você escolheu carro.")
}
function moto(){
alert("Você escolheu moto.")
}
</script>
</html>
The proposal is as follows, you must choose an option in select, and a warning should appear showing the chosen option. (Works in browsers: Edge and Firefox, but not in Chrome).
– Muka149
@Muka149 http://webbugtrack.blogspot.com.br/2007/11/bug-280-lack-of-events-for-options.html . Use attributes
data-type="carro"
and the eventonchange
to identify the type of vehicle.– Valdeir Psr
The right would be onchange in select, the click does not serve to select
– Sveen
Also not working in Opera, and IE11
– Sveen
You forgot to declare the
<title></title>
inside the head of your HTML. If you omit the tag<title>
the document is not validated as an HTML file. Source: https://www.w3schools.com/tags/tag_title.asp– Vinícius A. L. Souza