我需要一些Javascript和CSS幫助。我有一個工作正常的腳本,但是當我在頂部執行過濾功能時,我的CSS將不會運行,只有過濾後的結果將顯示在HTML頁面中。在執行JavaScript時尋求建議。運行javascript無法運行CSS
<script>
var createTable = function(){
var street = document.getElementById("search-street").value;
var suburb = document.getElementById("search-suburb").value;
var pc = document.getElementById("search-pc").value;
var type = document.getElementById("search-type").value;
var counter=0;
if (street == '' && suburb == '' && pc == '' && type == '') {
for(i=0;i<myArray.length;i++){
var id = myArray[i][4];
if(counter%3==0){
document.write("<div class='row'>");
}
document.write("<div class='col-sm-6 col-md-4'>");
document.write("<div class='thumbnail'>");
document.write("<div class='caption'>");
document.write("<p>" + myArray[i][3] + "</p>");
document.write("<p><a href='edit_property.php?id="+id+"' class='btn btn-default' role='button'>Edit</a> <a href='#delete_property.php?id="+id+"' class='btn btn-danger' role='button'>Delete</a></p>");
document.write("</div>");
document.write("</div>");
document.write("</div>");
counter++;
if(counter%3==0){
document.write("</div>");
}
}
} else {
for(i=0;i<myArray.length;i++){
var id = myArray[i][4];
if(counter%3==0){
document.write("<div class='row'>");
}
if(street==myArray[i][0] || suburb==myArray[i][1] || pc==myArray[i][2] || type==myArray[i][3]){
document.write("<div class='col-sm-6 col-md-4'>");
document.write("<div class='thumbnail'>");
document.write("<div class='caption'>");
document.write("<p>" + myArray[i][3] + "</p>");
document.write("<p><a href='edit_property.php?id="+id+"' class='btn btn-default' role='button'>Edit</a> <a href='#delete_property.php?id="+id+"' class='btn btn-danger' role='button'>Delete</a></p>");
document.write("</div>");
document.write("</div>");
document.write("</div>");
counter++;
}
if(counter%3==0){
document.write("</div>");
}
}
}
}
createTable();
</script>
哪裏CSS?你是什麼意思,「CSS不會運行」? – nnnnnn
我會考慮使用比20世紀90年代的'document.write'更先進的技術 - 說過,你說你的'CSS不會運行' - 並且你還沒有發佈任何CSS –