문제

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