Search code examples
jqueryshorttags

jquery shorttag issue


<script>
$("#commentInfo").html("I m here");
</script>

if I have a standard start/end tag, then jquery is fine

<span id='commentInfo' class="commentInfo"></span>
Testing

output

I m here 
Testing

if I have shorttag

<span id='commentInfo' class="commentInfo"/>

it only displays

I m here

how could configure the jquery to support shorttag ?


Solution

  • Short tags are closed. They are not meant to hold content or child elements. It's a self closing tag.

    What you're trying to do is invalid.

    Just stick to tags that open and close if you want child content and short tags if you don't need to add any child content to the HTML tag.