코드 정리 도와주실분 계신가요?

매출이 오르면 내리는 수수료! 지금 수수료센터에서 전자결제(PG)수수료 비교견적 신청해 보세요!
코드 정리 도와주실분 계신가요?

QA

코드 정리 도와주실분 계신가요?

본문

수정전 코드를 수정후 코드처럼 따로 뺐는데 

수정후 코드는 제대로 구현이 안되더라구요.

그래서 정리를 어떻게 해야하는지 모르겠습니다. 

혹시 알려주실 분 계신가요ㅠ

 


 
// 수정전
<input type="range" id="min_input" tabindex="0" value="600000" max="2000000" min="1000" step="1000" oninput="
                    this.value=Math.min(this.value,this.parentNode.childNodes[5].value-1);
                    var value=(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.value)-(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.min);
                    var children = this.parentNode.childNodes[1].childNodes;
                    children[1].style.width=value+'%';
                    children[5].style.left=value+'%';
                    children[7].style.left=value+'%';children[11].style.left=value+'%';
                    children[11].childNodes[1].innerHTML=numberWithCommas(this.value);" />
                    <input type="range" id="max_input" tabindex="0" value="1200000" max="2000000" min="1000" step="1000" oninput="
                    this.value=Math.max(this.value,this.parentNode.childNodes[3].value-(-1));
                    var value=(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.value)-(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.min);
                    var children = this.parentNode.childNodes[1].childNodes;
                    children[3].style.width=(100-value)+'%';
                    children[5].style.right=(100-value)+'%';
                    children[9].style.left=value+'%';children[13].style.left=value+'%';
                    children[13].childNodes[1].innerHTML=numberWithCommas(this.value);" />
 
 
 
// 수정후
 
<input type="range" id="min_input" tabindex="0" value="600000" max="2000000" min="1000" step="1000" oninput="rangeOne()" />
 
<script>
    function rangeOne() {
        this.value=Math.min(this.value,this.parentNode.childNodes[5].value-1);
                    var value=(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.value)-(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.min);
                    var children = this.parentNode.childNodes[1].childNodes;
                    children[1].style.width=value+'%';
                    children[5].style.left=value+'%';
                    children[7].style.left=value+'%';children[11].style.left=value+'%';
                    children[11].childNodes[1].innerHTML=numberWithCommas(this.value);
    }
</script>
 

이 질문에 댓글 쓰기 :

답변 1

함수에 데이터를 안넘겼으니 함수에서 처리가 안됩니다

oninput = "rangeOne(this)";

이렇게하고

function reangeOne(item) 파라미터를 지정해주고

해당 함수안에있는 this를 item으로 모두 변경하세요

답변을 작성하시기 전에 로그인 해주세요.
전체 0
QA 내용 검색
  • 개별 목록 구성 제목 답변작성자조회작성일
  • 질문이 없습니다.

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT