Reputation: 6316
I am working on the following code. I want to find out why I am not able to target the <img>
tag which only has the "award logos" alt
<img src="http://www.....jpg" alt="award logos">
<img src="http://www.....jpg" alt="Ranking">
<script>
$(document).ready(function() {
$('img [alt="award logos"]').wrap("<a href='http://google.com' </a>");
});
</script>
Technically, what I want to do is targeting all the images that has the specific alt attributes.
Upvotes: 0
Views: 91
Reputation: 28513
Remove space between img
and [alt="award logos"]
because of the space it is looking for child element of img
with attribute [alt="award logos"]
.
$(document).ready(function() {
$('img[alt="award logos"]').wrap("<a href='http://google.com'> </a>");
});
NOTE - you missed >
for a
(anchor) tag while wrapping img
, please correct it.
Upvotes: 6