i have select tag and I want to hide some options from it when user clicks on pull down element just above it. This works just fine in Firefox but not in Chrome and IE.
Code in question is this…
$('#myID').children().eq(0).hide();
$('#myID').children().eq(1).hide();
$('#myID').children().eq(2).hide();
$('#myID').children().eq(3).hide();
How can I solve this or at least troubleshot to see whats going on
I think we’re going to need to see the HTML it’s being applied to at the very least, and likely more of the JavaScript too.
How would I use chrome web dev console to see if any above statements are working?
jQuery fails silently, so you need to inspect every part of that line explicitly.
console.log($('#myID').length);
and so forth …
is it possible that my click doesnt work in Chrome because my alert box shows in Firefox but not in Chrome
$( "#myID option" ).click(function() {
var $result = $(this).index();
alert("Hello");
if ($result >=4){
$('#myID').children().eq(0).hide();
$('#myID').children().eq(1).hide();
wouldn’t surprise me. a click event makes more sense on the <select>
.
it is…#myID is the id of the
the event is on the option elements, not the select.
I actually change event from “click” to “change” and works now
system
Closed
January 4, 2018, 8:49pm
12
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.