Hi. You don't need to loop.
Guessing how your UI might work, try this...
- $("#pgNum").live("click, tap", function (e) {
- var v = $("#book").turn("view");
- $("#book").turn("page", parseInt($("#pgNum").attr("rel").split("x")[0]));
- $("#ContentTitle").fadeOut(1000);
- $("#CView").val(v[0] + " - " + v[1]);
- e.preventDefault; // these 2 lines stop the default <a> action, if needed
- return false;
- });
This fetches the href from the <a> with matching rel:-
- var href = $("#contents li a[rel=" + pgClicked + "]).attr("href");
If you're using jQuery 1.7 or later, change the .live() to .on() (just change the word).
Hope that helps.
Alan