$(function() { $('.namebox_open').click( function() { $("#namebox_open").load( '/do/school/namebox?schoolId=10072', function() { openNamebox(); $('.namebox_close').click( function() { closeNamebox(); $("#namebox_open").html(''); } ); } ); } ); }); function openNamebox() { $(".namebox_open").attr("style","display:none;"); $(".namebox_close").attr("style","display:display;"); } function closeNamebox() { $(".namebox_open").attr("style","display:display;"); $(".namebox_close").attr("style","display:none;"); }