Im not at my computer right now but it looks like you are not selecting the div to which you want your background image applied. Add the below line of code inside your function as the first line.
var MyObject = document.querySelector('#MyObject');
Edited. The script should be ok where it is, before the on click event call to it.
See if that suggestion makes any difference. If not lm back behind my computer later on so will sort it out for you if no-one else comes up with a solution or why your script its currently not working.
I'm so sorry!...
The script actually work both with my previous script and also with gentle help of Osgood.
The problem is because of "abc.jpg" had some problem.
this is strange because I've tryed it before and it work on photoshop...
I have saved this image again and now the script work fine.
Thank you all very much foro your help!!