Reputation: 28324
I have the following code
$(function() {
$('#totalRecords').css('visibility', 'hidden');
alert("hi");
});
Problem is that it doesnt hide my drop down which is
<span id="lblCodes" class="pol" style="top:4;left:209;">Codes</span>
<span id="totalRecords" class="pol" style="top:4;left:350;visibility:visible;">
<select id="startRecord" >
<option value="0"></option>
</select>
</span>
Is there a method for parent() or something. I thought jquery would just select from id. I see alert("hi") prompt but the dropdown doesnt get hidden
thanks
Upvotes: 0
Views: 180
Reputation: 957
I think you are choosing the wrong id for the selector. If you need to hide the dropdown, use $('#startRecord').hide(); OR $('#startRecord').css('display', 'none'); OR $('#startRecord').css('visibility', 'hidden');
Note: visibility and display are different in their functionality.
Upvotes: 0
Reputation: 17941
remove "visibility:visible" from style attribute and use $('#startRecord').hide();
Upvotes: 1
Reputation: 813
I would say you should use the "display" attribute and set it to "none" to hide an element. So your code would be:
$('#totalRecord').css('display', 'none');
And it should be "totalRecord" instead of "totalRecords"
Upvotes: 1
Reputation: 125528
did you not mean
$('#startRecord').hide();
You seem to have the wrong id in your selector for the dropdown. Also, visibility and display are quite different. Unless you want the hidden dropdown to still occupy the space, you'll want to use display
instead of visibility
Upvotes: 4