Js defines the object array (combined) multi-dimensional array method

Source: Internet
Author: User
The following small series will bring you a js definition object array (combined with) multi-dimensional array method. I think this is quite good. Now I will share it with you and give you a reference. Let's take a look at the small Editor. It's very easy to define arrays in php. However, if the character is written as a subscript in js, an error will occur, so we can combine it with the object.

Var top _ = {'index': 'homepage', 'user': 'user', 'tree': 'module tree'}; var all_list = [{"index ": [{'name': 'website topic management', 'url': '1.html '}, {'name': 'website topic management2', 'url ': '2.html '}]}, {"user": [{'name': 'user management', 'url': 'user.html'}, {'name': 'user add ', 'url': 'add.html '}]}, {"tree": [{'name': 'module tree management', 'url': 'manager.html'}, {'name ': 'module tree add', 'url': 'add_new.html '}, {'name': 'module tree add 333 add', 'url': 'add_ne3320.html'}];

A module tree array is defined above ....

In addition, it is good to retrieve data.

// Obtain the function return_left_menu_by_index (index) {var left _ = ''; for (var I in all_list) {for (var j in all_list [I]) of the left menu based on the subscript at the top. {if (j = index) {// default menu displayed // console. dir (all_list [I] [j]); for (var k in all_list [I] [index]) {// console. dir (k); var new_onclick = 'onclick = change_right_url ("'+ all_list [I] [index] [k]. url + '")'; left _ + ='

'+ All_list [I] [index] [k]. name +'

';}}} Return left _;}

The above js definition object array (combined) multi-dimensional array method is all the content shared by xiaobian. I hope to give you a reference and support for PHP.

For more articles on js definition object array (combined) multi-dimensional array method, refer to PHP!

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.