This should be the end, but I suddenly remembered a question. This approach is actually the same as the hover idea in jQuery, and here is the polling of the Dom element update, which means that every time the mouse moves the label There must be some data to be sent and received. It has no impact on the small piece of data above. However, it is not feasible to use this method in a large Case because its Dom element update may be a data stream of more than ten kb or even dozens of kb. , which undoubtedly brings great challenges to the performance of the Web page...
Therefore, I made another small change, that is, using Dom to reconstruct the hidden frame usage, in the page for the first time When loading, the Div corresponding to the first tag is loaded first, that is, the Div corresponding to the album. When the mouse moves to other tab tags, the element corresponding to the tag is appended (if the element exists, remove the hidden element) And display, if not present, append), and hide the Div tags corresponding to other Tab tags... This method has a name, called "Multi-stage download...", so that there is no need to update the elements every time, the code is as follows ...
//Hide tags
function tabs (i)
{
for(var j=1;j<5;j )
{
$("#tabcontent" j).hide();
}
$("#tabcontent" i).show();
var num,ids,ordnum;
var len= $("#tabcontent" i).length;//This sentence is very important, it is Eliminate the judgment of repeatedly loading elements (if the element exists, there is no need to append it again)
if(len==0)
{
switch(i)
{
case 1 :{ append(1,1,"f"); break;}
case 2:{ append(2,5,"s"); break;}
case 3:{ append(3,9, "t"); break;}
case 4:{ append(4,13,"fo"); break;}
}
}
}
//load Enter data
function append(i,j,type)
{
var str="
";
str ="
";
str ="
";
str ="
";
str ="
";
str ="
";
str ="
";
str ="
";
str ="
";
str ="
div>";
str ="
";
$("#tabcontent").append(str);
}
4. Design summary
The performance of the website has been improved. There will be no delay caused by overloading of page elements during the first load, nor due to the Dom tree. The page display performance is low due to constant updates...
As shown in the figure:
Source code download
/201010/yuanma/DomForm.rar
声明:この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。