클릭 이벤트에 대한 모든 값 (옵션)으로 <select> .... </ select> html 요소를 제거하려고합니다. 처럼
<span>Span First</span>
<select>
<option>opt 01</option>
<option>opt 02</option>
</select>
<span>Span Second</span>
<select>
<option>opt 11</option>
<option>opt 12</option>
</select>
다음과 같이 출력하고 싶습니다.
Span First Span Second
다음과 같은 코드를 사용하고 있습니다.
<script>
function removeTags(str)
{
if ((str===null) || (str===''))
return false;
else
str = str.toString();
return str.replace( /(<([^>]+)>)/ig, '');
}
document.write(removeTags('<html> Tutorix is <script> the best <body> e-learning platform'));;
</script>
위의 코드는 잘 작동하지만 <option> opt .. </ option> 내부의 값을 제거 할 수 없습니다.
누구든지 나를 도울 수 있습니까?
로 <select>
요소를 제거하십시오 .remove()
.
document.querySelectorAll("select").forEach(el => el.remove());
<span>Span First</span>
<select>
<option>opt 01</option>
<option>opt 02</option>
</select>
<span>Span Second</span>
<select>
<option>opt 11</option>
<option>opt 12</option>
</select>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다