Reputation: 448
I need a glyphicon icon like this :
<i class="glyphicon glyphicon-remove-circle"></i>
I want to append this icon using jquery to a paragraph,based on the results obtained from ajax call.
I tried this, but its not working.
var icon="<i class='glyphicon glyphicon-remove-circle' title='Insert an appropriate value'></i>";
$(idprop).append(icon);
"idprop" is an id to paragraph tag .Is this the correct way ??
Upvotes: 0
Views: 2689
Reputation: 38102
Since "idprop" is an id to paragraph tag
. You need to use #
to target element by id
:
$('#idprop').append(icon);
Upvotes: 2
Reputation: 146201
You already got the answer (you should use '#id'
) but I like this way:
var icon = $('<i/>', {
'class':'glyphicon glyphicon-remove-circle',
'title':'Insert an appropriate value'
});
$('#idprop').append(icon); // appends at last
// Most probably you need to use prepend
$('#idprop').prepend(icon); // appends at firstst
Upvotes: 0