This document describes the usage of jquerylogs in event.tar get. For more information, see
Event.tar get
Description: DOM element that triggers the event.
Thisvs event.tar get
In JS, thisks can be changed, but event.tar get will not change. It will always be the target DOM element for directly accepting events;
Similarities between thisand event.tar get
Thisand event.tar get are both dom objects. If you want to use the methods in jquey, you can convert them to jquery objects: sums (this(and counts (event.tar get );
This reminds me of an example previously written:
The Code is as follows:
// Del event
$ (". Del"). bind ("click", function (event ){
Var _ tmpQuery = $ (this); // Why should I add this sentence?
Var id = $ ("input [name = 'id']", $ (this). parents ("form: first"). attr ("value ");
Art. dialog. confirm ('Are you sure you want to delete this log? ', Function (){
$. Post ("myRun/managerlog_del.php", {id: id}, function (tips ){
If (tips = 'OK '){
Art. dialog. tips ('deleted successfully ');
$ (_ TmpQuery. parents ('tr: first ')). hide (); // if the first sentence is not added, $ (this) is used here ). parents ('tr: first ')). hide (); will not hide
// Because this is not the current class = "del" DOM object. It is the AJAX configuration object ajaxSettings of jQuery. Test: alert (this. url );
} Else {
Art. dialog. tips (tips, 5 );
}
});
Return true;
});
});
Now, we can hide the encoding code by using the encoding (event.tar get) method instead of using $ (_ tmpQuery. parents ('tr: first '). hide ();). The specific code is as follows:
The Code is as follows:
$ (". Del"). bind ("click", function (event ){
// Var _ tmpQuery = $ (this); this line of code can be deleted
Var id = $ ("input [name = 'id']", $ (this). parents ("form: first"). attr ("value ");
Art. dialog. confirm ('Are you sure you want to delete this log? ', Function (){
$. Post ("myRun/managerlog_del.php", {id: id}, function (tips ){
If (tips = 'OK '){
Art. dialog. tips ('deleted successfully ');
Parameters (event.tar get). parents ('tr: first '). hide ();
} Else {
Art. dialog. tips (tips, 5 );
}
});
Return true;
});
});
Use of event.targetand events (event.tar get)
The Code is as follows:
Untitled document