• Tự động thêm thẻ alt và title cho hình ảnh blogspot

    Chào các bạn tiếp tục series Tối ưu hóa blogspot - Tối ưu hóa blogger chuẩn seo blogspot - chuẩn seo blogger. Hôm nay mình sẽ chỉ cách cho các bạn Tự động thêm thẻ alt và title cho hình ảnh blogspot



    Để thực hiện được điều này, việc bạn phải làm đơn giản chỉ là thêm 1 đoạn script vào template Blogspot.

    Đăng nhập vào Blogspot, trong tab Template, chọn Edit Html.

    Sau đó bạn tìm thẻ đóng </body> và thêm đoạn script dưới đây vào bên trên thẻ </body>:



    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'/>
    <script type='text/javascript'>
    $(document).ready(function() {$('img').each(function(){var $img = $(this);var filename = $img.attr('src')$img.attr('alt', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));});});</script>
    <script type='text/javascript'>
    $(document).ready(function() {$('img').each(function(){var $img = $(this);var filename = $img.attr('src')$img.attr('title', filename.substring((filename.lastIndexOf('/'))+1, filename.lastIndexOf('.')));});});
    </script>



    Sau đó chọn Save Template.

    Chúc Bạn Thành Công.!
  • You might also like

    No comments:

    Post a Comment

Komentar

About me