我该如何编写客户端JavaScript来获取其源图像?
An image that is on the page?
You can do this with jQuery:
<body>
<!-- your content including the image -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
var myimg = $('img[src="/some/path/to/img.jpg"]');
});
</script>
</body>
This uses the tag-selector
(docs) along with the attribute-equals-selector
(docs) to get img
elements where the src
matches the source you want.
Use JQuery.
$("img[src='imageurl.jpg']")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.