Just want to ask how to create a element using jquery i am able to create a href using below code.
document.createElement("a");
How can i create a element inside another element , exactly below.
<a href="#"><i class="fa fa-list"></i></a>
You can use the append function with jQuery.
$("#add").click(function() {
$('<a href="#"><i class="fa fa-list"></i></a>').appendTo(document.body);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" integrity="sha384-dNpIIXE8U05kAbPhy3G1cz+yZmTzA6CY8Vg/u2L9xRnHjJiAK76m2BIEaSEV+/aU" crossorigin="anonymous">
<button id="add">Add Stuff</button>
$element, instead do $('<a href="#"><i class="fa '+icon+'").appendTo($element) if you want the new thing.fa- included inside the icon? Additionally, it will only not display (but will be in Chrome inspector) if there is no valid icon, so, that means you probably aren't inputting the right icon name$('#main').after().append('<a href="#"><i class="fa fa-list"></i></a>');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" integrity="sha384-dNpIIXE8U05kAbPhy3G1cz+yZmTzA6CY8Vg/u2L9xRnHjJiAK76m2BIEaSEV+/aU" crossorigin="anonymous">
<div id="main">
</div>