tags:

views:

12

answers:

1

Hi I just discovered jquery, but can't figure out how i can get all the imgs 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');
+2  A: 

You can use .attr() for this:

$(function() {
  $('.entry-content img').addClass('myClass yourClass')
                         .attr({ title: "some Title", rel: "some Rel" });
});
Nick Craver