im trying to get the value of an custom attribute in a datalist with no success, someone can help me?
The Datalist
<div class="form-group col-md-6">
<label for="sel_cidade">Cidade</label>
<input type="text" name="sel_cidade" id="sel_cidade" list="sel_municipio" class="form-control">
<datalist id="sel_municipio" name="sel_municipio">
<?php
foreach ($selectMunicipioIBGE as $r ) {
echo '<option data-value="' . $r->cidadeCodigo . '">' . $r->cidadeNome;
}
?>
</datalist>
<input type="hidden" name="sel_cid" id="sel_cid">
</div>
The JQuery
$("#sel_cidade").on("change", function () {
console.log($("#sel_municipio").val($("#sel_municipio").attr("data-value")));
});