我在我的xhtml文件中有一個javascript代碼。那就是:較小的運算符在javascript代碼中給出錯誤
<h:head>
<h:outputStylesheet library="css" name="styles.css" />
<script>
function dataTableSelectOneRadio(radio) {
var id = radio.name.substring(radio.name.lastIndexOf(':'));
var el = radio.form.elements;
for (var i = 0; i < el.length; i++) {
if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
el[i].checked = false;
}
}
radio.checked = true;
}
</script>
</h:head>
問題IST,裏面的for循環它給出了「<」經營者說,錯誤「元素的內容必須包含合式的字符數據或標記。」我認爲它認爲「<」的,即「身體一個HTML元素,HTML等,但我不知道我怎樣才能解決這個
感謝
編輯:?現在我試過,但仍然是一個錯誤。是否有語法錯誤,你看到
<script>
function dataTableSelectOneRadio(radio) {
var id = radio.name.substring(radio.name.lastIndexOf(':'));
var el = radio.form.elements;
for (var i = 0; i < el.length; i++) {
if (el[i].name.substring(el[i].name.lastIndexOf(':')) == id) {
el[i].checked = false;
}
}
radio.checked = true;
}
</script>
錯誤說:
myaccounts.xhtml:5:52 Expected) but found ;
for (var i = 0; i < el.length; i++) {
^
myaccounts.xhtml:5:57 Expected ; but found)
for (var i = 0; i < el.length; i++) {
^
http://stackoverflow.com/questions/4338538/javax-servlet-servletexception-error-parsing-page-xhtml-the-content-of-elemen出現工作 – Andreas