Reputation: 53
$("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
Upvotes: 0
Views: 46
Reputation: 11
I would write it this way
$("ul").append("<li><a href=\" \"><?php echo $this->session->userdata('username'); ?></a></li>");
or this way
$("ul").append("<li><a href=''><?php echo $this->session->userdata('username'); ?></a></li>");
Upvotes: 1
Reputation: 1823
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>
<ul></ul>
Hope this helps!
Upvotes: 1