-1
I am running a test on a plugin in worpdress with form that has select , where when the user selects the option with "value:9" emits an Alert ("Working") and if it does not select the this option emits an Alert("Not working")but this code I made only works on the browser console, when I put it in the file does not work
I tried with several parameters of jquery, but did not succeed.
JQUERY CODE
$('.bookly-js-select-service').change(function(){
if($(this).val() == '9'){
alert("Funcionando");
} else {
alert("Não funcionando");
}
});
HTML CODE
<select class="bookly-select-mobile bookly-js-select-service">
<option value="">Escolher serviço</option>
<option value="9">Avaliação Clínica</option>
<option value="10">Avaliação de retorno ao trabalho</option>
<option value="11">Exame Toxicológico</option>
</select>
*****I changed my jQuery code ***** But even then I did not succeed, even appears on the console, but the condition of if, no.
jQuery(document).ready(function($){
var eleLists = jQuery('.bookly-js-select-service:visible');
console.log(eleLists.length);
if(eleLists.length > 0){
jQuery(eleLists[0]).change(function($){
if(jQuery(this).val() == '9'){
alert("Funcionando");
} else {
alert("Não funcionando");
}
});
}
else
{
console.log("Componente ainda não foi carregado!!");
}
});
[![insert image description here][1][1]
Cara edits your question and also puts the code of your select . bookly-js-select-service, have you checked if it is not browser cache? WP always stays in the cache
– hugocsl
Edit your question and put the WP html code where select is. (runs a search and looks for more than one ".bookly-js-select-service"). There’s no way of knowing just from your script what’s going on.
– user12100
Here it is working normal, on the console and direct on the browser page
– hugocsl