Question

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.

Was it helpful?

Solution

You can do this:

if(url.split('?')[1].split('/')[1] == "user"){
   $('#user').collapse(); // this is pseudo code
}
else{
   $('#plan').collapse(); // this is pseudo code
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top