admin管理员组文章数量:1289741
<script type="application/javascript" language="javascript">
function showElement(elementID, show){
var element = document.getElementById(elementID);
if (element) {
element.className = (show ? element.className.replace(/hidden/gi, "show") : element.className + " hidden");
}
}
</script>
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="baseGrayMedium">
<td colspan="2">
(<a href="javascript:void(0);" onClick="showElement('evicChkLst',true);" class="nostyle">+</span></a>|<a href="javascript:void(0);" onClick="showElement('evicChkLst',false);" class="nostyle">-</span></a>) <B>Eviction Checklist</B>
</td>
</tr>
</table>
I get the Javascript error saying object expected and it points to onClick
event in the HTML code.. Could some one suggest me why so?
EDIT:
<script type="application/javascript" language="javascript">
function showElement(elementID, show){
var element = document.getElementById(elementID);
if (element) {
element.className = (show ? element.className.replace(/hidden/gi, "show") : element.className + " hidden");
}
}
</script>
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="baseGrayMedium">
<td colspan="2">
(<a href="#" onclick="javascript:showElement('evicChkLst',true);" class="nostyle">+</span></a>|<a href="#" onclick="javascript:showElement('evicChkLst',false);" class="nostyle">-</span></a>) <B>Eviction Checklist</B>
</td>
</tr>
</table>
Now the code looks some thing like the above
<script type="application/javascript" language="javascript">
function showElement(elementID, show){
var element = document.getElementById(elementID);
if (element) {
element.className = (show ? element.className.replace(/hidden/gi, "show") : element.className + " hidden");
}
}
</script>
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="baseGrayMedium">
<td colspan="2">
(<a href="javascript:void(0);" onClick="showElement('evicChkLst',true);" class="nostyle">+</span></a>|<a href="javascript:void(0);" onClick="showElement('evicChkLst',false);" class="nostyle">-</span></a>) <B>Eviction Checklist</B>
</td>
</tr>
</table>
I get the Javascript error saying object expected and it points to onClick
event in the HTML code.. Could some one suggest me why so?
EDIT:
<script type="application/javascript" language="javascript">
function showElement(elementID, show){
var element = document.getElementById(elementID);
if (element) {
element.className = (show ? element.className.replace(/hidden/gi, "show") : element.className + " hidden");
}
}
</script>
<table cellpadding="3" cellspacing="1" border="0" width="100%">
<tr class="baseGrayMedium">
<td colspan="2">
(<a href="#" onclick="javascript:showElement('evicChkLst',true);" class="nostyle">+</span></a>|<a href="#" onclick="javascript:showElement('evicChkLst',false);" class="nostyle">-</span></a>) <B>Eviction Checklist</B>
</td>
</tr>
</table>
Now the code looks some thing like the above
Share Improve this question edited Oct 22, 2021 at 7:04 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Nov 4, 2009 at 19:25 krishnakrishna 111 gold badge1 silver badge2 bronze badges3 Answers
Reset to default 3Your problem is: <script type="application/javascript" language="javascript">
It must be <script type="text/javascript" language="javascript">
I don't immediately see anything wrong in your snippet.
It's possible that formatting elsewhere in your script has messed up the definition or scope of showElement
. Try adding this link next to the others:
<a href="javascript:void(0)" onclick="alert(typeof showElement);">?</a>
It should alert function
if everything up to that point is good (or, at least, not alert undefined
).
I just had this error and it was because I had a form element that was trying to submit to an action that was invalid.
Mine was and that was not a valid action.
If you are still having this error you should verify syntax as well as that your form is submitting to a valid method.
This error indicates bad html syntax or invalid source.
本文标签: onclickObject expected error message in JavascriptStack Overflow
版权声明:本文标题:onclick - Object expected error message in Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741484940a2381356.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论