I am dynamically creating divs by incrementing their class names. Now i have a close button on top right corner of the divs and i want a particular div to hide when i click on close button.
Code:
var i=1;
var newImageBoxdiv = $(document.createElement('div')).attr({ class:"demo"+i, id:"image"});
newImageBoxdiv.innerHTML = "<img id='MyImage' />";
newImageBoxdiv.insertAfter('.demo');
i++;
$('#CloseWindow').click(function(){
?????
});
Everytime i create a div. I get its class name as demo1,demo2… and so on. What should i write in #CloseWindow function to hide the div i want to?
$(divSelector).hide()will hide the element selected$(divSelector).show()will show the element selected$(divSelector).toggle()will toogle show/hide on the element selectedHope this helps you!