Home  >  Article  >  Web Front-end  >  How to put jquery value into src of img tag

How to put jquery value into src of img tag

coldplay.xixi
coldplay.xixiOriginal
2020-11-26 13:40:172832browse

How to put the value of jquery into the src of the img tag: first create a new html file and introduce jquery; then enter the jquery code in the [<script>] tag in [index.html]; Finally, the browser can run the [index.html] page. </script>

How to put jquery value into src of img tag

The operating environment of this tutorial: Windows 7 system, jquery version 3.2.1. This method is suitable for all brands of computers.

How to put the jquery value into the src of the img tag:

1. First, open the html editor and create a new html file, for example: index.html , and introduce jquery.

How to put jquery value into src of img tag

2. In the <script> tag in index.html, enter the jquery code: <code>$('img').attr('src', ' small3.png');. </script>

How to put jquery value into src of img tag

#3. The browser runs the index.html page. At this time, jquery is used to successfully put the image address into the src of the img tag.

How to put jquery value into src of img tag

Related free learning recommendations: javascript (video)

The above is the detailed content of How to put jquery value into src of img tag. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn