Jquery-api-$.extend ()-example

Source: Internet
Author: User

Jquery-api-$.extend ()-example:

1 <!DOCTYPE HTML>2 <HTML>3 <Head>4   <Scriptsrc= "Http://cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></Script>5 </Head>6 <Body>7  8 <DivID= "Log"></Div>9  Ten <Script> One varObject1= { A Apple:0, - Banana: {weight: the, Price: -}, - Cherry: the the }; - varObject2= { - Banana: {Price: $}, - Durian: - + }; -   + /*merge object2 into Object1*/ A $.extend (Object1, object2); at /*Json.stringify Not all browsers support, IE67 can not, this is a compatibility of the judgment - The typeof json!== "undefined" is used to determine whether the JSON class exists, is executed, and does not invoke the custom method. */ - varPrintobj= typeofJSON!= "undefined" ?json.stringify:function(obj) { -   vararr= []; - $.each (obj,function(Key, Val) { -     varNext=Key+ ": "; in Next+=$.isplainobject (val)?Printobj (val): Val; -     /*test whether the object is a purely object (created with "{}" or "New Object")*/ to Arr.push (next); +   }); -   return "{ " +Arr.join (", ") + " }"; the }; *   $ $("#log"). Append (Printobj (Object1));Panax Notoginseng </Script> -   the </Body> + </HTML>

Jquery-api-$.extend ()-example

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.