Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
深入挖掘JavaScript对象的路径_Javascript_Jquery_Object - Fatal编程技术网

深入挖掘JavaScript对象的路径

深入挖掘JavaScript对象的路径,javascript,jquery,object,Javascript,Jquery,Object,我正试图在MultiLevelPushMenu插件中提取当前元素的根路径 所有者提供了将根级路径提取到文档上的方法 /** * Find path to root of selected menu level object * Provides chain collection of menu level objects (root menu level object to given menu level object), or false in case of error */ $(

我正试图在MultiLevelPushMenu插件中提取当前元素的根路径

所有者提供了将根级路径提取到文档上的方法

/**
 * Find path to root of selected menu level object
 * Provides chain collection of menu level objects (root menu level object to given menu level object), or false in case of error
 */
$('#menu').multilevelpushmenu('pathtoroot', $menuLevelObject);
我试着按照指南使用相同的方法,但我得到了HTMLLiobject,但无法深入到路径

我需要这个集合中字符串格式的路径,有什么帮助吗

这是我的密码

$(document).ready(function(){
// HTML markup implementation, overlap mode
$( '#menu' ).multilevelpushmenu({
containersToPush: [$( '#pushobj' )],
menuWidth: '25%',
menuHeight: '100%',
onItemClick: function() {
// First argument is original event object
var event = arguments[0],
// Second argument is menu level object containing clicked item (

element)
$menuLevelHolder = arguments[1],
// Third argument is clicked item (
element)
$item = arguments[2],
// Fourth argument is instance settings/options object
options = arguments[3];
    // You can do some cool stuff here before
    // redirecting to href location
    // like logging the event or even
    // adding some parameters to href, etc...
    var path = $('#menu').multilevelpushmenu('pathtoroot', $item);

    alert(path);
}
});
});

以下更新的示例应为您提供:

/All Categories/Devices/Mobile Phones/Super Smart Phone
单击最后一个元素-而不是当前获取的对象的字符串

$(文档).ready(函数(){
//HTML标记实现,重叠模式
$(“#菜单”)。多级按钮菜单({
containersToPush:[$('pushobj'),
menuWidth:“25%”,
menuHeight:“100%”,
onItemClick:function(){
//第一个参数是原始事件对象
变量事件=参数[0],
//第二个参数是包含单击项(元素)的菜单级对象
$menuLevelHolder=参数[1],
//第三个参数是单击项(元素)
$item=参数[2],
//第四个参数是实例设置/选项对象
选项=参数[3];
//你可以在这里做一些很酷的事情
//重定向到href位置
//比如记录事件,甚至
//正在向href添加一些参数,等等。。。
变量路径=$(“#菜单”).multilevelpushmenu('pathtoroot',$item);
//console.log(路径);
//log('element0:',路径[0]);
//log('element1:',路径[1]);
//console.log('--------------------------------------');
//log('element0内部html:',$(路径[0]).html());
var s='';//保存路径的字符串
对于(变量i=0,长度=path.length;i

所有类别
  • 装置
    • 手机
    • 电视
    • 摄像机
  • 杂志
  • 商场
    • 衣裳
      • 女装
      • 男装