JQuery11 data (): Cache

Source: Internet
Author: User

<!DOCTYPE HTML><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"><title>Untitled Document</title><Scriptsrc= "Jquery-2.0.3.js"></Script><Script>$(function(){        $('#div1'). attr ('name','Hello'); Alert ($ ('#div1'). attr ('name') ); document.getElementById ('Div1'). SetAttribute ('name','Hello'); Alert (document.getElementById ('Div1'). getattribute ('name') ); $('#div1'). Prop ('name','Hello'); Alert ($ ('#div1'). Prop ('name') ); document.getElementById ('Div1')['name'] = 'Hello'; Alert (document.getElementById ('Div1')['name'] ); $('#div1'). Data ('name','Hello'); Alert ($ ('#div1'). Data ('name') );});//DOM elements and objects are referenced to each other, and most browsers have memory leaksvarOdiv=document.getElementById ('Div1');varobj={};odiv.name=Obj;obj.age=Odiv;//A memory leak will occur$('#div1'). attr ('name', obj);//instead of worrying about memory leaks$('#div1'). Data ('name', obj); $ ('Body'). Data (' Age', obj);//data is the connection of DOM elements and objects indirectly through the cache. This prevents a memory leak. Such as. varCache= {//    1: {name:obj},2: {age:obj}};</Script></Head><Body><DivID= "Div1"XXX=" "></Div></Body></HTML>

JQuery11 data (): Cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.