换个思路,把图片的id传过去。然后在function 这样子写url = document.getElementById(id).getAttirbute("src");obj.style.background="url(\""+url+"\")";