为什么在asp.net中调用javascript函数时需要分号
当我没有尝试;服务器显示错误。
为什么最有必要让函数不用分号调用
考虑我有javascript代码为
函数myfunction(){
//代码部分
}
< asp:RadioButtonList ID =rblistGenderrunat =serveronclick =myfunction();>
为什么需要onclick方法的分号?
我必须在用户时执行我的代码更改单选按钮列表的值。
When I tried without ; the server shows error.
Why is it most necessary so that function doesn't call without semicolon
Consider I am having javascript code as
function myfunction(){
// code part
}
<asp:RadioButtonList ID="rblistGender" runat="server" onclick="myfunction();">
Why the semicolon at the onclick method is needed?
I have to execute my code whenever the user changes the value of the radio button list.
为什么用句号结束句子并以大写字母开头?所以我们知道你的句子何时开始和结束。同样的原因,js喜欢看到一个分号,它告诉它这是最后的陈述。我认为很多js实现都不需要;但是对于启动代码段的事情来说最重要的是。
Why do you end sentences with a period and start them with a capital letter? So we know when your sentences begin and end. Same reason that js likes to see a semi-colon, it tells it this is the final statement. I think a lot of js implementations don't require the ; but it is most important when it comes to things that start code segments.
if (x == 1)
x = x + 1;
如果x为1,则上述意味着增加x
The above means increment x if x is 1.
if (x == 1);
x = x + 1;
上述意味着如果x为1则什么都不做。然后总是增加x。
作为最佳实践,你应该总是使用它们。
The above means that if x is 1 do nothing. Then always increment x.
As best practice you should always use them.