Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery css() not working with visibility

Tags:

jquery

css

In the code below I have changed show() to css() and modified the visibility. For some reason it doesn't show up onclick.

Here is the HTML:

<td class="area">
    <img src="/def.jpg" />
</td>

<tr id="target" style="visibility:hidden">
    <td>This was hidden</td>
</tr>

and then the jQuery:

$("td.area").on("click", "img", function(){
    $("tr:hidden#target").css("visibility","visible");
});
like image 766
Satch3000 Avatar asked Dec 30 '11 23:12

Satch3000


2 Answers

The selector :hidden does not work with visibility just with display. Here is the jQuery documentation http://api.jquery.com/hidden-selector/

You have to try something different:

var t = $("#target");
if(t.css("visibility") == "hidden"){
    t.css("visibility", "visible"); 
}
like image 163
epignosisx Avatar answered Nov 20 '22 11:11

epignosisx


Why not just use $('tr#target'). See jsFiddle here.

like image 37
Selvakumar Arumugam Avatar answered Nov 20 '22 12:11

Selvakumar Arumugam