开发者

How do you simply hide an element without it collapsing in jQuery

开发者 https://www.devze.com 2022-12-23 22:49 出处:网络
I have a table of todos and on the le开发者_运维知识库ftmost column are normally checkboxes to mark completed. I want to hide those checkboxes untill a user hovers over a task, upon which that tasks c

I have a table of todos and on the le开发者_运维知识库ftmost column are normally checkboxes to mark completed. I want to hide those checkboxes untill a user hovers over a task, upon which that tasks checkbox becomes visible.

Currently when I hide the checkboxes using

$('table#incompleted_tasks tr td input[type="checkbox"]').css('display', 'none');

the actual column collapses and following columns are shunted left. This means when i hover over a task the checkbox is expanded but everything is shunted right and thus misaligned.

Id like to preserver that hidden columns width but how?


Use

$('table#incompleted_tasks tr td input[type="checkbox"]').css('visibility', 'hidden');

The element will not be shown, but the place for it will be “held occupied” for in the page flow.


You can set "visibility" to "hidden":

$('table#incompleted_tasks tr td input[type="checkbox"]').css('visibility', 'hidden');
0

精彩评论

暂无评论...
验证码 换一张
取 消