Thank you!. I've been thinking that it "might" be because the element changes? in that case, how would I make it re-register the click event when the element has been clicked?
On 5 Jan., 21:22, Ricardo Tomasi <ricardob...@gmail.com> wrote: > doesn't make any sense, there must be something else interfering with > your code. > > BTW, you can make that way more readable: > > $(".showEvents").click(function(e) { > var Calendar = $(this).parent().parent(), > ID = Calendar.attr('id').substr(4), > data = $('#data_+ID); > if (data.length) { > $(this).attr("src","images/down.png"); > data.hide(); > } else { > $('<tr/>').attr("id","data_"+ID) > .append('<td colspan="4">Test</td>') > .children('td').css({ > backgroundColor: Calendar.css('backgroundColor'), > height: '300px' > }).end().insertAfter(Calendar); > $this.attr("src","images/up.png"); > }; > > }); > > On Jan 5, 2:32 pm, revivedk <timsoren...@gmail.com> wrote: > > > Hi. > > I'm having a problem, where > > > $(".showEvents").click(function(e) { > > var CalendarID = $($(e.target).parent()).parent(); > > if ( $('#data_'+CalendarID.attr('id').substr(4)).length > 0 > > ) { > > $(e.target).attr({src : "images/down.png"}); > > $('#data_'+CalendarID.attr('id').substr(4)).hide(); > > } else { > > CalendarID.after('<tr > > id="data_'+CalendarID.attr('id').substr > > (4)+'"><td colspan="4" style="background-color:'+CalendarID.css > > ('background-color')+';height:300px;">Test</td></tr>'); > > $(e.target).attr({src : "images/up.png"}); > > } > > }); > > > will stop working after I have clicked the #showEvents 2 times. > > > <img border="0" class="showEvents" src="images/down.png"/ >