Get all the images within a class call post with jquery
Hi I just discovered jquery, but can't figure out how i can get all the imgs 开发者_JAVA技巧within a class and add a rel tag and set its title.
I understood that class can be added like this:
<script type='text/javascript'>
$(document).ready(function() {
$('.entry-content img').addClass('myClass yourClass');
});
</script>
But is there something to set title and rel? like
$('.entry-content img').addrel('myClass yourClass');
You can use .attr()
for this:
$(function() {
$('.entry-content img').addClass('myClass yourClass')
.attr({ title: "some Title", rel: "some Rel" });
});
精彩评论