<input type="number" placeholder="정가를 입력해주세요." class="price-input" name="price">
<span>원</span>
<div class="product-price-sale">
<input type="radio" name="persent" onclick="getPersent(30)">30퍼
<input type="radio" name="persent" onclick="getPersent(50)">50퍼
<input type="radio" name="persent" onclick="getPersent(65)">65퍼
</div>
<div class="sale-price">
<span></span>원에 판매됩니다.
</div>
let price = document.getElementsByName('price');
function getPersent(e) {
let priceSpan = document.querySelector('.sale-price > span');
if (e == 30) {
let persent30 = price[0].value * 30/100;
priceSpan.innerHTML = persent30;
price[0].style.textDecoration = "line-through";
price[0].style.textDecorationColor = "red";
price[0].style.color = "gray";
}
if (e == 50) {
let persent50 = price[0].value * 50/100;
priceSpan.innerHTML = persent50;
price[0].style.textDecoration = "line-through";
price[0].style.textDecorationColor = "red";
price[0].style.color = "gray";
}
if (e == 65) {
let persent65 = price[0].value * 65/100;
priceSpan.innerHTML = persent65;
price[0].style.textDecoration = "line-through";
price[0].style.textDecorationColor = "red";
price[0].style.color = "gray";
}
price[0].focus();
price[0].select();
}
이러고 나서 다시 price[0]을 클릭되면 textDecoration이랑 color 없애고 싶은데 if문을 어떤식으로 작성해야할지 모르겠어
모바일에서 질문이 안보여
어떡ㅎㅈ;
이러고 나서 다시 price[0]을 클릭되면 textDecoration이랑 color 없애고 싶은데 if문을 어떤식으로 작성해야할지 모르겠어
토글
아 나 그냥 ㅈㄴ 바보 였다 토글은 아닌데 다른걸로 해결함 ㄳ