본문 바로가기

[긴급] 버튼 사용 시 주의사항

라꼬즈 2025. 6. 19.

버튼 추가 양식을 사용하고 계신 분들은 html 편집 하는 곳의 </body> 바로 위에 아래 코드를 복사 붙여넣기 하세요. 코드 전체를 복붙하셔야합니다.

<script>
document.addEventListener('DOMContentLoaded', function() {
    const style = document.createElement('style');
    style.textContent = `
        .lgz-btn {
            display: inline-block;
            margin: 0 auto;
            padding: 12px 24px;
            border: 1px solid #2563eb;
            background-color: #3b82f6;
            color: white;
            text-decoration: none;
            cursor: pointer;
            font-family: inherit;
            font-size: 1rem;
    				font-weight: 600;
            border-radius: 8px;
            outline: none;
            box-shadow: none;
            transition: none;
            text-align: center;
        }
        
        .lgz-btn-wrapper {
            text-align: center;
        }
    `;
    document.head.appendChild(style);

    const oldClassNames = ['cnb-button1', 'cnb-button2', 'cnb-button3', 'cnb-button4', 'cnb-button5', 'cnb-button6'];
    
    oldClassNames.forEach(className => {
        document.querySelectorAll(`.${className}`).forEach(element => {
            function getTextFromElement(el) {
                let text = '';
                for (let node of el.childNodes) {
                    if (node.nodeType === Node.TEXT_NODE) {
                        text += node.textContent;
                    } else if (node.nodeType === Node.ELEMENT_NODE) {
                        text += getTextFromElement(node);
                    }
                }
                return text;
            }
            
            const allText = getTextFromElement(element);
            const cleanText = allText.replace(/\s+/g, ' ').trim();
            
            element.innerHTML = '';
            if (cleanText) {
                element.appendChild(document.createTextNode(cleanText));
            }
            
            // 부모 요소에 중앙 정렬 클래스 추가
            if (element.parentElement) {
                element.parentElement.classList.add('lgz-btn-wrapper');
            }
            
            element.classList.remove(className);
            element.classList.add('lgz-btn');
            element.removeAttribute('style');
        });
    });
});
</script>

댓글