开发者

Get all the images within a class call post with jquery

开发者 https://www.devze.com 2023-01-18 15:38 出处:网络
Hi I just discovered jquery, but can\'t figure out how i can get all the imgs 开发者_JAVA技巧within a class

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

精彩评论

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

关注公众号