当我点击子li元素时如何保持父li打开

时间:2016-11-03 07:49:57

标签: javascript html

public static String getWord(String textOfTextView, int offsetPosition)
    {
        int endpositionofword = 0;
        int startpositionofword = 0;
       for (int i = offsetPosition; i<textOfTextView.length();i++)
       {
           if (i==textOfTextView.length()-1) {
               endpositionofword = i;
               break;
           }
           if (textOfTextView.charAt(i)==' ') {
               endpositionofword = i;
               break;
           }

       }
        for (int i = offsetPosition; i>=0;i--)
        {
            if (i==0) {
                startpositionofword = i;
                break;
            }
            if (textOfTextView.charAt(i)==' ') {
                startpositionofword = i;
                break;
            }

        }
        return textOfTextView.substring(startpositionofword,endpositionofword);

    }

2 个答案:

答案 0 :(得分:0)

如果您使用php渲染并在菜单项上单击页面刷新,则可以添加类,例如&#34; active&#34;到父li(s),并在样式中添加li.active {display:block}或类似的样式来显示隐藏的元素

答案 1 :(得分:0)

最后我对laravel路线的状况感到满意

<li @if(Request::path() == "mypage_v2/applications/lists" || Request::path() == "mypage_v2/applications/register") class="active opened")@endif>