I have a simple HTML navbar that I do not want to recreate for every page. I know I can do this simply using PHP, but is there a simple way to do it using jQuery?
If so, is it “corrcect” to do so?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s pretty simple to create HTML in javascript (at least if using jQuery) and insert it into every document that includes the .js file, all you have to do is something like:
On the other hand it’s a bad idea to do this unless there is some good reason, as mixing HTML into your javascript is consider bad practice.
It will give users without JS problems, and it will create more problems for you since the elements now are inserted dynamically and events and listeners will have to be set up accordingly!