I put into DOM div tag, using jquery append() method
I want that before putting, set div tag some css property, for example visibility: "hidden"
this doesn’t work:
$(document).ready( function () {
$(".child").css({
visibility: "hidden"
});
$("body").append('<div class="child"></div>');
});
How to solve this problem ?
Your code cannot work since it does not create a new CSS rule but just searches for matching elements – and the new element cannot be found yet. The easiest way is to create the element, set its CSS properties and then add it to the DOM:
Another option would be creating a new CSS rule matching the selector.