3
I am using this jquery already tried to use change also but does not run
<script>
$(document).ready(function(){
$("#select-native-fc").on('click', function(){
if($("#select-native-fc").val() == "ASM2")
{
alert('Teste');
}
});
</script>
Select code:
<div class="ui-field-contain">
<label for="select-native-fc">Linhas de Assembly:</label>
<select name="select-native-fc" id="select-native-fc" class="assy">
<option value="http://www.youtube.com">Assembly 1</option>
<option value="ASM2">Assembly 2</option>
<option value="ASM3">Assembly 3</option>
<option value="ASM4">Assembly 4</option>
<option value="ASM5">Assembly 5</option>
<option value="ASM6">Assembly 6</option>
<option value="ASM7">Assembly 7</option>
<option value="ASM8">Assembly 8</option>
<option value="ASM9">Assembly 9</option>
<option value="ASM10">Assembly 10</option>
<option value="ASMX">Assembly X</option>
<option value="ASMY">Assembly Y</option>
<option value="ASMZ">Assembly Z</option>
</select>
</div>
I needed that by clicking on some option redirects to another page I am using jquery for mobile events only works for IE but in google Chrome does not work and even for mobile platform I am using these libraries of jquery below:
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
The action must be taken in the
onChange
and not in theonClick
– rray
Forehead
.on('change',
, as @rray suggested.– Sergio
I tried not to
– daniel lajiskin
Didn’t work out you mean what? didn’t display the Alert?
– rray
yes does not perform anything already tried to do right up in select onChange="Alert('test');"
– daniel lajiskin
You tried to use
.assy
instead of#select-native-fc
debug?– Emerson Barcellos
tried as well and it didn’t work out as close as I could in jquery was with onclick only it runs Alert in direct select or even open the checkbox
– daniel lajiskin
Then use
<script>
$(document).ready(function(){
 

$("#select-native-fc").change(function(){
 var val = $("#select-native-fc").val();
 alert(val);
 //your code
});
});

</script>
will work.– Emerson Barcellos
nothing should still be anything in the library
– daniel lajiskin
Depending on the library you should use the
.live
rather than.change
or.on
– Emerson Barcellos
I made a fiddle here. https://jsfiddle.net/oeo267j4/
– Marconi
you didn’t forget to close $(Document) didn’t?? I saw a "});" so the code checks error and doesn’t execute
– Fleuquer Lima