好奇怪啊,
$("body").on("click","#btntest", function () {
$(this).attr("disabled", "true");
})
里面的$(this),按理解应该指的是“body”啊,可是为什么又指到[data]上去了呢?
好奇怪啊,
$("body").on("click","#btntest", function () {
$(this).attr("disabled", "true");
})
里面的$(this),按理解应该指的是“body”啊,可是为什么又指到[data]上去了呢?
2014-09-05
好了看看真实的on的调用方法吧:(从1.7版本开始)
.on( events, [selector,][data,] function )
events
Type: String
One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
selector
Type: String
A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.
data
Type: Anything
Data to be passed to the handler in event.data when an event is triggered.
handler
Type: Function( Event eventObject )
A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false.
或者是:
.on( events [, selector ] [, data ] )
events
Type: PlainObject
An object in which the string keys represent one or more space-separated event types and optional namespaces, and the values represent a handler function to be called for the event(s).
selector
Type: String
A selector string to filter the descendants of the selected elements that will call the handler. If the selector is null or omitted, the handler is always called when it reaches the selected element.
data
Type: Anything
Data to be passed to the handler in event.data when an event occurs.
举报