javascript - jQuery css "click" doesn't work after change in selected month in calendar -
this question has answer here: event binding on dynamically created elements? 19 answers i'm working on dynamic calendar allows user click on individual days change whether they're available or unavailable. works it's supposed until select month or year. once happens "click" event on individual cells/days doesn't work. // changes cell background of calendar var changecolor = function(temp) { // if cell background white -> change green if(temp.css('background-color') == "rgba(0, 0, 0, 0)") { temp.css('background-color', 'green'); // if cell background green -> change red } else if (temp.css('background-color') == "rgb(0, 128, 0)") { temp.css('background-color', 'red'); } else { // else change white temp.css('background-color', '');