jquery - style.backgroundImage javascript method not working for me on any browser (FireFox, Chrome, IE, Safari) -
I can change background image with CSS but in this situation I need to use javascript, imga name " BTN is in 1-1. PGN "and its" IMG "directory (Child Directory) where my HTML index file is in the root directory, the image path is working in CSS, but javascript
& Lt; Input type = "button" id = "btn_1" class = "btn_hidder" value = "notification" /> & Lt; Input type = "button" id = "btn_2" class = "btn_hidder" value = "document" />
And here is the JavaScript code ...
document.getElementById ("btn_1"). Style.backgroundImage = "url ('img / btn1- 1.png')";
Also check the screen shots.
Parent Directory (HTML File):
Child Directory (JS File):
My script has been fully added because working with its Alert () and all other JavaScript Codes are working. I tried the internal way of javascript but nothing happened.
I know that you did not ask for this, but I love jquery Note: I Did not test. You may still have a passage problem as told by Billy.
$ (document) .ready (function () {$ ('# btn_1'). CSS ('background-image', 'IMG / BTN 1-1.png');} );
Comments
Post a Comment