[英]How to get an image by its source?
我该如何编写客户端JavaScript来获取其源图像?
页面上的图像?
您可以使用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>
along with the attribute-equals-selector
to get img
elements where the src
matches the source you want. 这将使用tag-selector
和attribute-equals-selector
来获取src
与所需源匹配的img
元素。
使用JQuery。
$(“ img [src ='imageurl.jpg']”)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.