[英]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.