I would like my code to work like this: There are few DIVs with similar ID and similar content. When I click on CLICK button i need already existing DIV id="object" to prepend to parent div of the click button. My code works just for the first of DIVs.
HTML
<div id="article">
<p>...CONTENT</p>
<div class="click">CLICK</div>
</div>
<div id="article">
<p>...CONTENT</p>
<div class="click">CLICK</div>
</div>
CSS
#article{
width: 100%;
height: 200px;
background: gray;
color: white;
}
.click{
cursor: pointer;
color: red;
}
#object{
width: 100%;
height: 100px;
background: red;
}
Jquery
$(".click").click(function(){
$('#object').prependTo("#article");
});