I am fairly new to Jquery and CSS/Html. I have a CSS tree structure and I want to add more Children to the parent when an outside button is click. Can you guys help please?
$(document).ready(function(){
$('a').on('click',function(){
$('a').not(this).removeClass('highlighted');
$(this).toggleClass('highlighted');
if ($('a').hasClass('highlighted')){
$('.btn').prop('disabled', false);
}
else {$('.btn').prop('disabled', true); }
});
$('.btn').click(function(){
var new1 = "<li><a href='#'>AAA</a></li>"
var new2 = $('.highlighted').children().append(new1);
})
});
These are what I wrote. Basically I am highlighting the 'li' I am clicking. And try to append a new children 'li' after my current li.