Reputation: 139
When I resize the window, the blue block is changing his size. If I click on blue block, I add symbol * to it. But if I click on the blue block, resize window, and again click on resized block, instead of one *, will add a lot of symbols *.
What's the problem? I need add one symbol *, after I resize the window.
function c_click() {
$('.blue-block').click(function(){
$('.blue-block').append('<div>*</div>')
});
}
$(window).ready(function(){
c_click();
})
$(window).resize(function(){
c_click();
})
Upvotes: 0
Views: 128
Reputation: 332
jQuery allows for multiple event handlers attached to one element. In this case, each time resize()
is evoked, you register a click
handler, which results in the multiple '*'
Upvotes: 2