简体   繁体   中英

Bootstrap 3 navbar change dynamically

Using the basic navbar in bootstrap, what is the best way to show the username and login status, after the user logs in? In other words, how do I dynamically update the navbar menu, after the user logs in, to show that they are logged in ?

Well, you can put whatever you like inside your navbar. Personally, I wouldn't update its structure on the client after login is performed (are you implementing AJAX login?). The easiest way is to simply submit login information, check the login status with your serverside language and fill the navbar accordingly in your template.

In the weird case you really want to update it directly on the client, you can go for a simple js callback (after the AJAX login is performed), assign a specific ID to the navbar section you would like to update and change its content (with jQuery it would be something as simple as $("#YOUR-ID").text("Whatever User Data"); ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM