为什么有些Javascript函数放在$()中?

时间:2016-06-17 09:01:15

标签: javascript

我注意到Javascript中的某些功能包含在 $()中。例如:

(0xffffffffL << 32) ==
(0xffffffffL << (32 % Long.SIZE) ==
(0xffffffffL << (32 % 64) ==
(0xffffffffL << 32) ==
0xffffffff00000000L

与简单相反:

$(function() {
     //do something here
});

我知道Javascript函数不需要这个表示法,所以$()实际上做了什么?

1 个答案:

答案 0 :(得分:0)

Jquery的$(document).ready(function(){});

的简写

https://learn.jquery.com/using-jquery-core/document-ready/

顺便说一句,你的第二个功能永远不会被执行。如果您希望执行(),则需要添加function() { //do something here }();

[MembershipPasswordAttribute(MinRequiredNonAlphanumericCharacters = 4, MinRequiredPasswordLength = 7, MinNonAlphanumericCharactersError = "Alpha", MinPasswordLengthError = "MIN Length")]
[DataType(DataType.Password)]
public string Password { get; set; }

[System.ComponentModel.DataAnnotations.Compare("Password",ErrorMessage  ="{0} and {1} should be same")]
public string ComparePassword { get; set; }