I have a website that will fade out a section of my website, load new content in, and fadeIn. There\'s a feature I had where a picture would get big when you click on it (it\'s
.click()
is a shorthand of .bind('click')
, which only binds to elements that are already in the page
To bind events to current and future elements, you must use .live()
// If the user makes a picture bigger
$(".makePictureBig").live('click',function() {
//code
});
Edit:
As of jQuery 1.7, live is deprecated. You can use jQuery on:
$(".makePictureBig").on('click', function() {
//code
});
Or, for delegated event handlers:
$("#wrapper").on('click', '.makePictureBig', function(){
//code
});