1

I have a php code which generates pagination links.

I have ol > li list..

li has titles like Page 1, page 2, next page, previous page, last page, first page

I want only the links -> Previous Page and Next Page .. So I can use jQuery and search within li

Using this, I get all the links. [Used binded click to know check if the ]

jQuery(document).ready(function(){
jQuery('#custom_pagination li').find('li').attr('title','Next Page').click(function(){alert("clicked");})
});

I only want 2 of them with searching the title attr. HOw do i do it.?

tx

Tudor Constantin
  • 26,330
  • 7
  • 49
  • 72
Umesh Moghariya
  • 3,063
  • 6
  • 21
  • 23

1 Answers1

1

With .attr( attributeName, value ), you are setting the atrribute on every li!

See: http://api.jquery.com/attr/

.attr( attributeName, value ) attributeNameThe name of the attribute to set. valueA value to set for the attribute.

You need to only select the LI's with the right title. See below:

Similar problem: Get element by title jQuery

Solution:

$("li[title='Next Page'],li[title='Previous Page']").click(function(){alert("clicked");})

Updated answer:

$("#custom_pagination").find("a[title='Next Page'],a[title='Previous Page']").click(function(){alert("clicked");})
Community
  • 1
  • 1
Derk Arts
  • 3,432
  • 2
  • 18
  • 36