The JavaScript style object provides the access to the backgroundImage property that enables you to change the background image of targeted HTML element. In this sample we have used the HTML anchor tag hyperlinks to change the background image of the HTML Div tag. The onclick event of HTML hyperlinks raise the client side click event that allow you to call the JavaScript functions. In the HTML code we have also used the HTML hidden field control to store the value of Array index that is used in the JavaScript code to display the background image stored at that array index.
JavaScript DOM features Used
1. document object
2. getElementsById method
3. style object
4. backgroundmage property
Try the sample below to understand the functionality of using Hyperlink tags of HTML to change the background image of div tag dynamically using JavaScript.