끝 부분의 div (bottom_box)에 HTML 내용을 기반으로하는 사용자 정의 클래스가 있어야하는 javascript 생성 테이블에 문제가 있습니다. 코드는 다음과 같습니다 :div에 고유 한 클래스를 추가하는 Jquery/Javascript
<script type="text/javascript">
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "servicereport2.xml", false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
if (xmlDoc) {
var x = xmlDoc.getElementsByTagName("ISSUE");
for (i = 0; i < x.length; i++) {
document.write("<div class='box_lrg'><div class='box_top'></div><div class='box_middle'><table border='0'>");
document.write("<tr><td class='title'><h2>");
document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
document.write("</h2></td><td class='issueid'><strong>IssueID: </strong><br />");
document.write(x[i].getElementsByTagName("ISSUEID")[0].childNodes[0].nodeValue);
document.write("</td><td class='status'><strong>Status: </strong><br />");
document.write(x[i].getElementsByTagName("STATUSID")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
document.write("<tr><td colspan=3 class='description'>");
document.write(x[i].getElementsByTagName("TICKETDESCRIPTION")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
document.write("<tr><td></td><td class='updated'><strong>Last Updated: </strong><br />");
document.write(x[i].getElementsByTagName("UPDATEDON")[0].childNodes[0].nodeValue);
document.write("</td><td class='author'><strong>Author: </strong><br />");
document.write(x[i].getElementsByTagName("AUTHOR")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
document.write("</table>");
document.write("</div><div class='box_bottom'>");
document.write(x[i].getElementsByTagName("CATEGORY")[0].childNodes[0].nodeValue);
document.write("</div></div>");
category = $('.box_bottom').html();
if (category == 'Notifications') {
$(".box_bottom").addClass("notifications");
}
category = $('.box_bottom').html();
if (category == 'VO')
{
$(".box_bottom").addClass("VO");
}
}
}
else {
document.write("<h3><span class='blue'>There are no issues at the moment.</span></h3>");
}
당신은 JQuery와 루프에 포함되어 있지만, 단지 모든 bottom_box div를 동일한 수준을 적용 볼 수 있듯이 - 그들은 모든 카테고리의 첫 번째 항목입니다 XML 태그. 첫 번째 "카테고리"가 VO이고 두 번째가 "알림"이면 EO가 모두 VO로 적용됩니다.
어떤 도움을 환영합니다.
왜 모든 document.write 및 중복 jQuery ?? – lifetimes
그런 식으로 document.write를 사용할 수 없습니다! 'document.write ("");'당신이 생각하는대로하지 않습니다! 그리고 페이지가 완전히로드 된 후에는 document.write를 사용하지 않아야합니다. – epascarello
[무엇?] (http://catmacros.files.wordpress.com/2009/07/i_dont_even_cat.jpg?w=720) [자바 스크립트 템플릿에서 배우기] (https://developer.mozilla.org/en -US/docs/JavaScript_templates) 귀하의 삶이 바뀝니다. –