On button click, I'm adding a css to the <head>
:
$("head").append("<link id='#color_1_css' href='" + newCssHref +"' type='text/css' rel='stylesheet' />");
which adds to <head>
:
<link id="#color_1_css" rel="stylesheet" type="text/css" href="http://domain.com/styles/colors/f69548/f69548.css">
On another button click I need to remove it again. I tried the following, which doesn't work for some reason:
$('html').on('click', '.clear-color-picker', function(events){
var id = $(this).attr('data-parentID').replace('background_color','');
$('#' + $(this).attr('data-parentID')).setColor('');
$('#' + id).css('background-color','');
if (id == 'main-color') {
console.log('clicked');
$('#color_1_css').remove();
}
})
Any ideas?
Because your id starts with
#
?