Not recognising closest span
My HTML looks something like the following:
- <label for="myTextBox">
- Name:<span style="color:red;">*</span>
- <input type="text" id="myTextBox"></input>
- </label>
In my document ready I have a function which runs 'on blur' of the textbox and hides the span. The following code DOESN'T work to hide the span:
- $('#myTextBox').closest('span').hide();
I'm currently using the code below which DOES work but was wondering why the above code doesn't....
- $('#myTextBox').parent().children(':first').hide();
Thanks.