I'm

Developer, Designer, Photographer

GET IN TOUCH

  • Buk-gu, Busan, Republic of Korea
  • ungdoli0916@naver.com
  • Kakao ID : Ungdoli
Your message has been sent. Thank you!
(즐거웅코드) 제이쿼리 margin 변경하기

· 즐거'웅' 코드 (Source)/HTML & CSS & JAVASCRIPT
2021. 4. 16. 17:09

반응형
jQuery
1
2
3
<script>
    $("(대상)").css("margin", (값));
</script>
예제 소스
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
 
<input type="number" id="margin_value" placeholder="margin 값 입력"/>
<button onclick="test()">margin 변경하기</button>
 
<div id="test_obj"></div>
 
<style>
    div {
        width: 200px;
        height: 50px;
        border: 1px solid #bbbbbb;
        background-color: #fbfbfb;
    }
</style>
 
<script>
    function test() {
        var margin_value = $('#margin_value').val();
        $("#test_obj").css("margin", margin_value);
    }
</script>
구현 예시
반응형