的OnClick = QUOT; createComment();"不起作用 [英] OnClick="createComment();" doesn't work
问题描述
我是JS的新手。我按下定义为的按钮
I'm a newbie in JS. I'm pressing the button defined as
<input type="button" value="Create a Comment" OnClick="createComment();">
我的脚本功能是
function createComment() {
alert("1")
}
当按下按钮时,以下代码将无效,但当我将名称更改为somethingelse时,它可以正常工作
when pressing the button the following code won't work but when I change the names to somethingelse it works
<input type="button" value="Create a Comment" OnClick="somethingelse();">
function somethingelse() {
alert("1")
}
我多次检查过文档中没有使用任何createComment名称。我还注意到在jquery库中使用了createComment,但它似乎不是一个函数,但我不确定它是做什么的。
I've checked multiple times there isn't any createComment name used in the document. I also noticed createComment is used in jquery library but it doesn't seem like a function but I'm not sure what it does.
<head>
<meta charset="utf-8">
<title>Parse Testing On Desktop</title>
<meta name="description" content="My Parse App">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/styles.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://www.parsecdn.com/js/parse-1.3.2.min.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
</head>
JQuery
// Check if getElementsByTagName("*") returns only elements
support.getElementsByTagName = assert(function( div ) {
div.appendChild( doc.createComment("") );
return !div.getElementsByTagName("*").length;
});
createComment名称有什么特别之处,还是jquery,为什么?
Is there something special with createComment name or is it jquery and why?
推荐答案
似乎 document.createComment
作为特殊功能存在 document
object。它可能是保留的,因此您将无法将其用作函数名称。
It seems document.createComment
exists as a special function for the document
object. It's probably reserved, and thus you wouldn't be able to use it as a function name.
在此处查看更多信息: https://developer.mozilla.org/en-US/docs/Web/API/document.createComment
See more here: https://developer.mozilla.org/en-US/docs/Web/API/document.createComment
这篇关于的OnClick = QUOT; createComment();"不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!