Hongmu Notes
Home Language Notes Add an onclick to the image img to refresh the image on click
Language Notes JavaScript

Add an onclick to the image img to refresh the image on click

Add an onclick to the image img to refresh the image on click

You can use the following code to add an onclick event to the image so that the image is refreshed after being clicked:

<img src="your-image-url.jpg" onclick="this.src=this.src+'?'+new Date().getTime();" />

When the image is clicked, this code adds a timestamp to the image's URL, which causes the browser to think this is a new URL and refresh the image.

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

js move the mouse up to modify the style attribute

js move the mouse up to modify the style attribute Language Notes JavaScript

When the mouse hovers over the element, the color changes to red; when the mouse leaves the element, the color changes to black. To retrieve an element by its ID: `document.getElementById()`; Event handler for mouse hover: `onmouseover`; Event handler for mouse leave: `onmouseout`.<!DOCTYPE html><html lang= "en">...
👁 130

Recommended reading

Empire CMS modifies PHP and directly sets the article calling conditions that are less than the article publishing time (newstime)

Empire CMS modifies PHP and directly sets the article calling conditions that are less than the article publishing time (newstime) Program Notes Empire cms

Continue with the previous article! "A method to publish tens of millions of articles regularly without manual intervention in the dynamic mode of Empire CMS"! In this article, your website can store tens of millions of articles, and ensure that you do not need to automatically review and publish every day! But you need to modify the call of the template and set it to: newstime &lt;= '.time().'After thinking about it, I found that some websites have too many calls. If you fix them one by one...
👁 442
(Adaptive Mobile Version) Responsive car rental website template (PBootCMS); Download used car sales and rental company website template – 0464

(Adaptive Mobile Version) Responsive car rental website template (PBootCMS); Download used car sales and rental company website template – 0464 Practical Collection pbootcms Template

This set of Baidu MIP architectural decoration PbootCMS website templates is adaptive to the mobile phone. The design style is professional and modern, suitable for displaying curtain wall materials, decoration projects and decoration cases. Supporting Baidu MIP helps improve mobile SEO effects and attract more traffic. Template display Installation instructions Website backend:/admin.php Account: admin Password: admin Unzip password: www.4s5.cn phase...
👁 52
Environmental Water Management Website Template 0042

Environmental Water Management Website Template 0042 Practical Collection Yiyou template

This set of eyoucms templates is suitable for the environmental water treatment industry. The design style is professional and environmentally friendly, and can display water treatment projects, water treatment projects and technical solutions. It helps environmental water companies demonstrate their strength online and attract government and corporate customers. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Summary of common problems in the installation of Yiyou CMS Yiyou CMS (Ey...
👁 55
Responsive training platform teaching software website template 0836

Responsive training platform teaching software website template 0836 Practical Collection Yiyou template

This EyouCMS responsive template is ideal for training platform and educational software companies. Its educational technology-oriented design is perfect for showcasing online training platforms, teaching software, course resources, and technical solutions. It helps education technology firms present their brand online and attract both school and corporate clients. Template Overview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Common Questions About EyouCMS Installation...
👁 31
(Adaptive mobile version) Responsive minimalist personal blog self-media pbootcms template article blog website source code download 0465

(Adaptive mobile version) Responsive minimalist personal blog self-media pbootcms template article blog website source code download 0465 Practical Collection pbootcms Template

An adaptive mobile phone electronic eye monitoring and security electronic equipment PbootCMS website template. The design style is technological and safe, suitable for displaying surveillance probes, security systems and intelligent hardware. It helps security technology companies display their products online and attract home and business customers. Template display Installation instructions Website backend:/admin.php Account: admin Password: admin Unzip password: www.4s5.cn Related...
👁 57
Heavy Industry Steel Machinery Website Template 0043

Heavy Industry Steel Machinery Website Template 0043 Practical Collection Yiyou template

An eyoucms website template targeting the heavy industry steel machinery industry. The design style is tough and grand, and can display steel products, heavy machinery and industrial scenes. It helps heavy industry companies establish a strong brand image online and attract industrial customers. Template display Installation instructions Website backend: /login.php Account: admin Password: admin Related articles Summary of common problems in Yiyou CMS installation Yiyou CMS (E…
👁 40