ajax成功后,在单击的菜单中添加一个活动类

时间:2016-10-12 09:00:04

标签: jquery ajax

function zeetapro_help_details(app_function_id){
        var adminrootpath = $('#adminrootpath').val();
        var appname = $('#appsName').val();

        $.ajax({
        url:adminrootpath + appname + "/self_load_menu_help",
        type:"POST",
        dataType:"HTML",
        data:{app_function_id:app_function_id},
        success:function(data)
        { 
             $('#help-container').html(data);

        }
    });

}
<ul id="tree3" class="box-head nav nav-tabs nav-custom menu_help tree" data-toggle="tabs">
<li class="" onclick="zeetapro_help_details(36);"></li>
<li class="" onclick="zeetapro_help_details(51);"></li>
<li class="" onclick="zeetapro_help_details(256);"></li>
<li class="" onclick="zeetapro_help_details(166);"></li>
</ul>

如何在每次ajax成功后向点击的li菜单添加一个活动类,在调用函数onclick事件时加载一些内容成功

1 个答案:

答案 0 :(得分:2)

添加&#34; &#34;在你的函数参数

示例 -

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
            this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    CircleImageView imageView = (CircleImageView)findViewById(R.id.imageView);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(DashboardMain.this, "image", Toast.LENGTH_SHORT).show();
        }
    });

然后在js中更改你的功能

<li class="" onclick="zeetapro_help_details(this, 36);"></li>