728x90
์ ์ด์ฟผ๋ฆฌ : ์คํ์ผ ๊ด๋ จ ๋ฉ์๋
์ค๋์ JQuery์ ์ฃผ์ ๋ฉ์๋๋ค ์ค, ์คํ์ผ๊ณผ ๊ด๋ จ๋ ๋ฉ์๋๋ฅผ ์์๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
1. css() ๋ฉ์๋
์คํ ๋ถ๋ฅ | ํ์ |
---|---|
์ทจ๋ | $("div").css("width"); |
์์ฑ, ๋ณ๊ฒฝ | $("div").css("background-color", "red").css("padding", "10px"); |
$("div").css({"background-color: "red", padding: "10px"}); | |
์ฝ๋ฐฑ ํจ์ |
$("div").attr("width", function(index, w) { // index๋ ๊ฐ div ์์์ index 0, 1, 2 // w๋ ๊ฐ div ์์์ width ๊ฐ return css ์์ฑ // ๊ฐ div ์์์ css ์์ฑ์ ์์ฑ ๋ฐ ๋ณ๊ฒฝํฉ๋๋ค. }); .... <div>๋ด์ฉ</div> <div>๋ด์ฉ</div> <div>๋ด์ฉ</div> |
๋ค์์ css() ๋ฉ์๋์ ์ฌ์ฉ ์์ ์ ๋๋ค.
2. width, height ๊ด๋ จ ๋ฉ์๋
๋ฉ์๋ ์ข ๋ฅ | ์ค๋ช |
---|---|
width() | ์์์ ๊ฐ๋ก ๊ธธ์ด๋ฅผ ์ทจ๋, ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. |
innerWidth() | padding์ด ์ ์ฉ๋ ์์์ ๊ฐ๋ก ๊ธธ์ด๋ฅผ ์ทจ๋, ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. |
outerWidth() |
border์ margin์ด ์ ์ฉ๋ ์์์ ๊ฐ๋ก ๊ธธ์ด๋ฅผ ์ทจ๋, ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. outerWidth()๋ ์์์ width๊ฐ + ์ขใ์ฐ border๊ฐ outerWidth(true)๋ ์์์ width๊ฐ + ์ขใ์ฐ border๊ฐ + ์ขใ์ฐ margin๊ฐ |
height() | ์์์ ๋์ด๋ฅผ ์ทจ๋, ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. |
innerheight() | padding์ด ์ ์ฉ๋ ์์์ ๋์ด๋ฅผ ์ทจ๋, ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. |
outerHeight() |
border์ margin์ด ์ ์ฉ๋ ์์์ ๋์ด๋ฅผ ์ทจ๋, ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. outerHeight()๋ ์์์ height๊ฐ + ์ใํ border๊ฐ outerHeight(true)๋ ์์์ height๊ฐ + ์ใํ border๊ฐ + ์ใํ margin๊ฐ |
๋ค์์ width, height ๊ด๋ จ ๋ฉ์๋์ ์ฌ์ฉ ์์ ์ ๋๋ค.
3. ์์น ๊ด๋ จ ๋ฉ์๋
๋ฉ์๋ ์ข ๋ฅ | ์ค๋ช | |
---|---|---|
offset() | $("์์").offset().left | html ๊ธฐ์ค์ผ๋ก left ๊ฐ์ ์ทจ๋ํ ์ ์์ต๋๋ค. |
$("์์").offset().top | html ๊ธฐ์ค์ผ๋ก top ๊ฐ์ ์ทจ๋ํ ์ ์์ต๋๋ค. | |
$("์์").offset({left: 10, top: 10}) | html ๊ธฐ์ค์ผ๋ก left, top ๊ฐ์ ๋ณ๊ฒฝํ ์ ์์ต๋๋ค. | |
position() | $("์์").position().left | ๋ถ๋ชจ ์์ ๊ธฐ์ค์ผ๋ก left ๊ฐ์ ์ทจ๋ํ ์ ์์ต๋๋ค. |
$("์์").position().top | ๋ถ๋ชจ ์์ ๊ธฐ์ค์ผ๋ก top ๊ฐ์ ์ทจ๋ํ ์ ์์ต๋๋ค. |
๋ค์์ ์์น ๊ด๋ จ ๋ฉ์๋์ ์ฌ์ฉ ์์ ์ ๋๋ค.
728x90
'JQuery' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์ ์ด์ฟผ๋ฆฌ : ์์ฑ ๊ด๋ จ ๋ฉ์๋ (5) | 2022.09.04 |
---|---|
์ ์ด์ฟผ๋ฆฌ : ํด๋์ค ๊ด๋ จ ๋ฉ์๋ (3) | 2022.09.04 |
์ ์ด์ฟผ๋ฆฌ : ํ์ ์ ํ์ (5) | 2022.09.01 |
์ ์ด์ฟผ๋ฆฌ : ํํฐ ์ ํ์ (10) | 2022.08.30 |
์ ์ด์ฟผ๋ฆฌ : ์์ฑ ์ ํ์ (7) | 2022.08.30 |
๋๊ธ