I need to put in a menu from a script file so that I can only need to make changes in one place to reflect across the project.
$(document).ready(function()
{
var str = "<h3>Menu</h3><ul class='nav vertical-nav'>";
str.append("<li><a href='staff_home.php?var01=<?php echo $userVar; ?>&var02=1' ></i>Chair</a></li>");
str.append("<li><a href='staff_home.php?var01=<?php echo $userVar; ?>&var02=3' ></i>Secretary</a></li>");
str.append("<li><a href='staff_home.php?var01=<?php echo $userVar; ?>&var02=2' ></i>Treasurer</a></li>");
str.append("<li><a href='staff_home.php?var01=<?php echo $userVar; ?>&var02=4' ></i>Admin</a></li>");
str.append("</ul>");
$('#insert-menu').html(str);
});
Now the above example is purely appending strings, which does not work.
I am new to jquery, so I am learning about the DOM to achieve this.
Now I can find documentation on inserting html files, but not really a lot on how to add code directly.
When I do the <h3> tag by itself it works, but when I start adding attributes (I think) that is where the problem lies.
Am I on the right track here?