2
I have a dynamically filled component
<select id="selectTeste">
<option value='1' exigeIdade='true'>item 1</option>
<option value='2' exigeIdade='true'>item 2</option>
<option value='3' exigeIdade='false'>item 3</option>
<option value='4' exigeIdade='true'>item 4</option>
</select>
and I have a jquery function that needs to use the exigeIdade
, ex:
//se alterar o comboProcedimento, verifica a idade
$("#selectTeste").on("change", function () {
atualizaProfissional(exigeIdade); //Como pegar a propriedade exigeIdade?
});
How to send the demand property via parameter?
In that case, all I have to do is add the word
data-
before the name of my attribute? can bedata-exigeIdade
?– Italo Rodrigo
May
data-exigeIdade
yes, but note that I wrotedata-exige-idade
, because HTML is case insensitive, and at the time of recovering this value you will have to use the whole name in case, that way -.data('exigeidade')
. That’s why I usedexige-idade
, in addition to being a good practice for writing html tags/properties. :)– Pedro Camara Junior
got it, thanks
– Italo Rodrigo
It worked well in simple html, but when I use this code in
bootstrap-select
does not work. Any hint?– Italo Rodrigo
my mistake, it worked yes.
– Italo Rodrigo