Lestah Lestah - 1 month ago 6
jQuery Question

how can i append a list item

$("ul").append("<li><a href=""><?php echo $this->session->userdata('username'); ?></a></li>");

This is giving me an error on my console it says
Uncaught SyntaxError: missing ) after argument list

Answer Source

Change the "" of the href to '' otherwise they close your string. Here is a working example:

$(function() {
  $("ul").append("<li><a href=''><?php echo $this->session->userdata('username'); ?></a></li>");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


Hope this helps!