Change the URL of an image:
The src property sets or returns the value of the src attribute of an image.
The required src attribute specifies the URL of an image.
Note: The src property can be changed at any time. However, the new image inherits the height and width attributes of the original image, if not new height and width properties are specified.
The src property is supported in all major browsers.
Return the src property:
Set the src property:
Value | Description |
---|---|
URL |
Specifies the URL of the image. Possible values:
|
Return Value: | A String, representing the URL of the image. Returns the entire URL, including the protocol (like http://) |
---|
Return the URL of an image:
The result of x will be:
HTML reference: HTML <img> src attribute