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.

1 Answers1

0
$(document).on('click', '.nav-link.disabled', function(e) {
    if(shouldBeDisable === true){
       e.preventDefault();
     }
})
Jonathan Dion
  • 1,651
  • 11
  • 16
  • While this code snippet may be the solution, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-‌​code-based-answers) 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. – Adam Apr 13 '17 at 15:17