I have 2 different url which are:

  1. index.php?r=admin/plan/list
  2. index.php?r=admin/user/list

And 2 accordion which have the id="user" and id="plan". Now I want to get the "plan" and "user" between the 2 slash in the url to identify which section I'm in and to let accordion decide which will be collapses.

Example: if I'm in user section, the accordion which had id="plan" will be collapse.

Is it possible to do that? Or have any better way to identify which accordion must be collapsed? Thank you so much.

有帮助吗?

解决方案

You can do this:

if(url.split('?')[1].split('/')[1] == "user"){
   $('#user').collapse(); // this is pseudo code
}
else{
   $('#plan').collapse(); // this is pseudo code
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top