0

I have a search button on right side of navigation bar. But depending on some condition I have to sometimes disable the search button. How to do that in bootstrap? Please find below code snippet:-

html = html.concat([
            "      </ul>",
            "    <ul class='nav navbar-nav navbar-right'>",
            "      <li class=\"nav-item\"><a class=\"nav-link disabled\" href='",baseUrl><span class=\"glyphicon glyphicon-search\"></span></a></li>",
            "    </ul>",
            "  </div><!--/.nav-collapse -->",
            "   </div>",
            "   </nav>"
        ]);

Thanks in advance.

0

1 Answer 1

0
$(document).on('click', '.nav-link.disabled', function(e) {
    if(shouldBeDisable === true){
       e.preventDefault();
     }
})
Sign up to request clarification or add additional context in comments.

1 Comment

While this code snippet may be the solution, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.