After making changes from original to changed code boxes, I now get Uncaught Type error: Undefined is not a function. Any ideas as to why? Thanks
Original:
$('.comment').click(function(e){
alert("click");
e.preventDefault();
$(".slidingDiv2").slideToggle();
});
Changed:
$(document.body).on('click', '.comment' ,function(){
alert("click");
e.preventDefault();
$(".slidingDiv2").slideToggle();
});
Easiest way might be to set it to display:none
in your css
, so it is hidden until your click event ( $('.comment').click(function(e){...
) is fired.
CSS:
.slidingDiv2 {
display:none;
}
$(document.body)
is not a valid selector, use $('body')