开发者

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" });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜