Use jquery to find the page number

I have an issue where I need to disable to drop down when the page number is greater than 1.

Using the Inspector, here is the html for the universal page widget.

<a href="javascript:__doPostBack('p$lt$ctl07$pageplaceholder$p$lt$ctl01$RowLayout$RowLayout_3$UniversalPager$pagerElem','1')">1</a>

As the user clicks through the $pagerElem with change.  I need to use a click event when this anchor is clicked and determine what page it is on and then disable and drop down if the page number > 1

Any ideas on how I can grab the page number from this html.

Thanks.
sherbug1015Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
does __doPostBack() emit an Ajax request or does the url on the browser change?  Also , are you using some js library?
sherbug1015Author Commented:
The url on the browser does not change, so this is probably an Ajax request.  We are using jquery 1.4 library
hieloCommented:
get the following useful extensions and save them as "jquery-extras.js":
http://wowmotty.blogspot.com/2010/05/jquery-selectors-adding-contains-exact.html

Then import the file after jquery.  After that you can use:
if( $('a:containsExact(1)').length )
	{
		$('#states').attr('disabled','disabled');
	}

Open in new window


Complete example below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<script type="text/javascript" src="/javascript/jquery-1.4.0.min.js"></script>

<!--  Source: http://wowmotty.blogspot.com/2010/05/jquery-selectors-adding-contains-exact.html -->
<script type="text/javascript" src="/javascript/jquery-extensions.js"></script>

<script type="text/javascript">
$(function(){
        //upon load, the <select> is disabled if there is an <a> that "equals" 1 -- meaning that it cannot
        // leading or trailing blanks
	if( $('a:containsExact(1)').length )
	{
		$('#states').attr('disabled','disabled');
	}
	
});
</script>

</head>
<body>
<a href="javascript:__doPostBack('p$lt$ctl07$pageplaceholder$p$lt$ctl01$RowLayout$RowLayout_3$UniversalPager$pagerElem','1')">1</a>

<select id="states" name="states">
	<option value="">Make a Selection</option>
	<option value="1">Alaska</option>
	<option value="2">Hawaii</option>
</select>
</body>
</html>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.