안녕하세요, 각 페이지의 폴더를 인식하도록 자바 스크립트를 가져 오려고합니다. 폴더 이름에 따라, if else 문을 사용하여 해당 폴더 이름을 innerHTML에 추가하고 싶습니다. if else, else if, else 문으로 작동하는 데 문제가 있습니다.Else, Else If, Else - 문자열 기준 URL
<div id="countryVal"></div>
그리고 자바 스크립트 : 어떤 제안이 매우 극명하게 될 것이다
var outputData = document.getElementById('clothingVal');
if (window.location.search.search(/Men/)) {
document.getElementById('clothingVal');
outputData.innerHTML = outputData.innerHTML + ': ' + 'Australia';
}
else if (window.location.search.search(/Women/)) {
document.getElementById('clothingVal');
outputData.innerHTML = outputData.innerHTML + ': ' + 'New Zealand';
}
else {outputData.innerHTML = outputData.innerHTML + ': ' + '';
};
여기
는 HTML 코드입니다.
달성하려는 작업을 이해하는 데 어려움이 있습니다. 그냥'document.getElementById ('clothingVal');'행은 아무 것도하지 않습니다. –
음 ... JS에는''clothingVal''이 있고 HTML에는''countryVal''이 있습니다. –