John Stab John Stab - 1 year ago 71
Javascript Question

JQuery - How to get the THIS for inner EACH

I have inner each like

$('a[id^="Page"]').each(function () {
if ($(this).attr("id") == pageId) {
$('[id="' + pageId + '"]"').each(function () {

How to access the current element since THIS is from previous EACH?


Answer Source

you can use the callback's second argument to get the element like so:

 $('a[id^="Page"]').each(function (index, element) {
         if ($(element).attr("id") == pageId) {
                  $('[id="' + pageId + '"]"').each(function (j, pageElment) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download