var $buttom=[];
//
function addBtn() {
var $dom = $("<button> " + iPP + "</button>");
$dom.on("click",function(){
console.log($(this).html());
});
$buttom.push($dom);
$.each($buttom,function(i,n){
$("-sharptest1").append(n);
});
};
//
function del(){
$("-sharptest1").empty();
};
//
function recov(){
$.each($buttom,function(i,n){
$("-sharptest1").append(n);
});
};
//2
function resetEve(){
$.each($buttom,function(i,n){
n.on("click",function(){
console.log($(this).html());
});
});
del();
$.each($buttom,function(i,n){
$("-sharptest1").append(n);
});
};
//1:
//:,log,,.
addBtn();
del();
recov();
//2:
//:,log,del(),resetEve(),,
//,del().append,.
addBtn();
del();
resetEve();
//3:
//:,log,,resetEve(),,
//,del().append,.
addBtn();
//del();
resetEve();
problem: events bound by $dom, via $dom saved with variables will lose their effect with empty ();
- Why is the event bound through the $dom variable lost? the variable name is still there. In general understanding, its event should also be there. Why is it lost?
- Why can I store this $dom variable through an array in mode 2? The array in this is obviously a pointer, pointing to the variable of $dom. I can"t think of the difference. But there must be something different. What"s the difference?
with regard to events, there must be something wrong with me. Or rely on the place, hope the master to show the way.