$( function() { $(".jobsinrighttop").find(".xiala:eq(0)").click( function() { var obj = $(this).prev(); var top = obj.offset().top + obj.outerheight(true) + $(document.body).scrolltop(); var left = obj.offset().left + $(document.body).scrollleft(); $("#provincedroplist").css( { // "top" : top + "px", // "left" : left + "px" } ).slidedown("fast"); } ).end().find(".xiala:eq(1)").click( function() { var obj = $(this).prev(); var top = obj.offset().top + obj.outerheight(true) + $(document.body).scrolltop(); var left = obj.offset().left + $(document.body).scrollleft(); $("#citydroplist").css( { //"top" : top + "px", // "left" : left + "px" } ).slidedown("fast"); } ); $("#provincedroplist li,#citydroplist li").hover( function() { $(this).addclass("current"); }, function() { $(this).removeclass("current"); } ); $("#provincedroplist li").mousedown( function() { $("#pid").val( ( $(this).attr("val") == "" ) ? "----" : $(this).text() ); $("input[name='p_id']").val( $(this).attr("val") ); $("#citydroplist li").hide(); if ( $(this).attr("val") == "" ) { $("#citydroplist li").show(); } else { $("#citydroplist li:first").show(); $("#citydroplist li[pid='" + $(this).attr("val") + "']").show(); } } ); $("#citydroplist li").mousedown( function() { $("#cid").val( ( $(this).attr("val") == "" ) ? "请选择市" : $(this).text() ); $("input[name='c_id']").val( $(this).attr("val") ); } ); $(document).click( function() { $("#provincedroplist,#citydroplist").hide(); } ); $(".jobsinrighttop").submit( function() { if ( $("input[name='jobsea']").val() == "" || $("input[name='jobsea']").val() == "请填写职位名称" ) { if ( $("input[name='p_id']").val() == "" && $("input[name='c_id']").val() == "" ) { $("input[name='jobsea']").css("color","#f00"); return false; } } } ); $("input[name='jobsea']").focus( function() { $("input[name='jobsea']").css("color","#000"); if ( $("input[name='jobsea']").val() == "请填写职位名称" ) { $("input[name='jobsea']").val(""); } } ).blur( function() { if ( $("input[name='jobsea']").val() == "" ) { $("input[name='jobsea']").val("请填写职位名称"); } } ); } );