admin管理员组文章数量:1431426
I have a very simple input tag:
<input id="DAhour" type="number" style="width:50px; font-size: xx-small; visibility:hidden">
which at first has to be not visible. Then if I change a bobox to the correct index it should bee visible. I managed to get the bobox and the selected item correctly but I cannot make the input tag visible. I tried with:
$("#DAhour").css("visibility", "visible");
but it doesn't work because if I check the visibility with
$("#DAhour").is(":visible")
it stays always equal to false. Then, when the bobox changes again I should be able to make it not visible again, si I tried again with
$("#DAhour").css("visibility", "hidden");
I have a very simple input tag:
<input id="DAhour" type="number" style="width:50px; font-size: xx-small; visibility:hidden">
which at first has to be not visible. Then if I change a bobox to the correct index it should bee visible. I managed to get the bobox and the selected item correctly but I cannot make the input tag visible. I tried with:
$("#DAhour").css("visibility", "visible");
but it doesn't work because if I check the visibility with
$("#DAhour").is(":visible")
it stays always equal to false. Then, when the bobox changes again I should be able to make it not visible again, si I tried again with
$("#DAhour").css("visibility", "hidden");
Share
Improve this question
edited Oct 16, 2015 at 9:18
Sam Chahine
6402 gold badges20 silver badges61 bronze badges
asked Oct 16, 2015 at 9:03
ayashaayasha
1,2515 gold badges31 silver badges51 bronze badges
0
3 Answers
Reset to default 4Because when you use visibilty rule, even though the element is not visible it consumes space in DOM. So, jQuery's visible selector will consider it as visible.
Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero.
Elements with
visibility: hidden
oropacity: 0
are considered visible, since they still consume space in the layout.
If you want to really hide the element use the display rule, ie display: none
or the short hand method .hide()/show()
try using $("#DAhour").show()
and $("#DAhour").hide()
methods
Try to check the visibility with:
if($("#DAhour").css("visibility")!== "hidden")
And change visibility with
$("#DAhour").css("visibility","hidden");
$("#DAhour").css("visibility","visible");
本文标签: javascriptJQueryInput tag change visibility attributeStack Overflow
版权声明:本文标题:javascript - JQuery - Input tag change visibility attribute - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745582219a2664686.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论