I encountered a strange issue where the code below works perfectly fine when directly pasted into the browser (chrome console). However, it does not work when executed from my source file.
<script type="text/javascript" >
$(".test").click(function(){
$(this).parent().find("div").toggle();
});
</script>