JS dynamically loads data binding events jquery delegate() method

The delegate() method adds one or more event handlers to the specified element (a child element of the selected element) and specifies the function to run when these events occur.


Event handlers using the delegate() method apply to current or future elements (such as new elements created by JavaScript).

The syntax is very simple $(selector).delegate(childSelector,event,data,function)

Parameter Description

selector Required, the parent node of the element to be controlled

childSelector Required. Specifies one or more child elements to which event handlers are attached.

event Required. Specifies one or more events to attach to the element. Multiple event values ​​separated by spaces. Must be a valid event.

data Optional. Specifies additional data to be passed to the function.

function Required. Specifies a function to run when an event occurs.

delegate ’s function is called by a common parent element of a certain type

 Control the right-click event shielding of the new navigation page
 

document.oncontextmenu=function(){return true;}//先取消屏蔽右键
		//table导航页再禁止右键
		$("#jerichotab").delegate(".jericho_tabs", "contextmenu",function(e){
			e.preventDefault();
			return false;
		});


 

Guess you like

Origin blog.csdn.net/zhaofuqiangmycomm/article/details/133789078