IT/development

[jQuery] jQuery ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ table tr ์ˆจ๊น€์ฒ˜๋ฆฌ

์•Œ ์ˆ˜ ์—†๋Š” ์‚ฌ์šฉ์ž 2022. 11. 24.

๋ชฉ์ฐจ

image source:https://unsplash.com/s/photos/jquery

๋ฒ„ํŠผ ํด๋ฆญ ์‹œ table์˜ tr์˜์—ญ์„ ์ˆจ๊น€์ฒ˜๋ฆฌํ•˜๋Š” ์˜ˆ์ œ

// ์ฒดํฌ๋ฐ•์Šค๊ฐ€ ์ฒดํฌ ๋˜์–ด ์žˆ์œผ๋ฉด table tr display none์ฒ˜๋ฆฌ ์˜ˆ์ œ
function check() {
	$("#ch").change(function(){
        if($("#ch").is(":checked")){
        	$("tr#one").css("display", "");	
        	$("tr#two").css("display", "");
        }else{
        	$("tr#one").css("display", "none");	
        	$("tr#two").css("display", "none");
        }
    });
}

 

"$(#ch)"์— change์ด๋ฒคํŠธ๋ฅผ ์คฌ๊ณ  ์ฒดํฌ์—ฌ๋ถ€๋ฅผ ์ฒดํฌํ•ด์„œ ์กฐ๊ฑด์ฒ˜๋ฆฌํ•œ ๊ฐ„๋‹จํ•œ ์˜ˆ์ œ

๋‚ด์šฉ์ด ๋„ˆ๋ฌด ๊ฐ„๋‹จํ•˜๊ธด ํ•˜๋‹ค.

๋Œ“๊ธ€