javascript - Can i check value of onclick="" with jquery? -


i working on ajax / php pagination system , having problem adding class active right link style selected.

so question can value of onlclick="" jquery?

my links shown as:

<li><a href='#' onclick='fetchresults(" + adresultsdata.pages[i] + ");'>" + adresultsdata.pages[i] + "</a></li> 

now want see number inside onclick="fetchresults()" add class highlightactivepage if current active link/page.

example:

lets clicked on link 5, is:

<li><a href='#' onclick='fetchresults(5);'>5</a></li> 

i have function check/output current page is:

adresultsdata.current_page 

aka

paginationhtml += pagespan.innerhtml = "<br>page " + adresultsdata.current_page + " of " + adresultsdata.number_of_pages; 

is somehow possible add class "highlightactivepage" a-tag same value adresultsdata.current_page ?

sorry if seems bit messy,

i suggest following quick fix (not elegant).

instead of showing value 5 directly function fetchresults(), create attribute used purpose, let's "page" or "p" shorter code.

you should have then:

<li><a href='#' p='5' onclick='fetchresults(this);'>5</a></li> 

put keyword "this" function. function have that:

function fetchresults(this) {     $(this).addclass('highlightactivepage');     // more code.... }  

this represent node clicked.

hope helps.

paul


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -