javascript - Adding rel= attributes to Bootpag Pagination for SEO -


im using bootpag pagination ajax call , i'm looking way add rel='next' rel='prev' links, got far adding them based on 'active' class 'prev' attribute on previous links , 'next' on next links use pagination attributes don't change.

the code additional attributes

if ( $('ul.pagination li').hasclass('active') ) {    $('li.active').prevall().attr("rel","prev");  }  if ( $('ul.pagination li').hasclass('active') ) {    $('li.active').nextall().attr("rel","next");  } 

the code pagination

$('#pagination_container').bootpag({     total: ${myordersdata.totalnumberofpages},     leaps: true,     firstlastuse: true,     first: '| <',     last: '> |',     wrapclass: 'pagination',     activeclass: 'active',     disabledclass: 'disabled',     nextclass: 'next',     prevclass: 'prev',     lastclass: 'last',     firstclass: 'first' })   .on("page", function(event, /* page number here */ num){     $.ajax({       type:"get",       url: "ordersbypagenumber?pagenumber="+num,     })     .done(function(data) {      $("#previousorders").html( data );     });   }); 

the pagination works fine addition of rel attributes on links.

edited clarification

<ul class="pagination bootpag"> <li data-lp="1" class="first" rel="prev">   <a href="javascript:void(0);">| &lt;</a> </li> <li data-lp="1" class="prev" rel="prev">   <a href="javascript:void(0);">&lt;</a> </li> <li data-lp="1" class="">   <a href="javascript:void(0);">1</a> </li> <li data-lp="2" rel="next" class="active">   <a href="javascript:void(0);">2</a> </li> <li data-lp="3" rel="next">   <a href="javascript:void(0);">3</a> </li> <li data-lp="3" class="next" rel="next">   <a href="javascript:void(0);">&gt;</a> </li><li data-lp="3" class="last" rel="next">   <a href="javascript:void(0);">&gt; |</a> </li> </ul> 

based on above code, in 'page' event handler:

.on("page", function(event, /* page number here */ num){      var $lis = $('.bootpag li').not('.first, .last, .prev, .next'),         $active = $('.bootpag li.active');      $lis.removeattr('rel');     $active.prev().attr('rel', 'prev');     $active.next().attr('rel', 'next');      ...the rest of code 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -