It's common practice to copy this variable to local self (var self =
this).

And it works fine.

$("select.zmiana_daty_wysylki").each(function ()
{
    var self = this;
    /*
        do some stuff to select
    */
   $('option', this).each(function ()
   {
        /* operate on each option, and self will point to select. */
    });
});


On 20 фев, 13:41, pambuk <wojtek.zymo...@gmail.com> wrote:
> I know that jQuery overwrites 'this', but I never had a problem with
> that until now.
> Maybe some of you know a better way or maybe I took a wrong turn
> somewhere.
>
> What I'm basically trying to do is to iterate selects (dropdowns), do
> something with them, and while I'm iterating selects, iterate options
> of a every select, it looks like this (except for the inside logic):
>
> $("select.zmiana_daty_wysylki").each(function (i) {
>     var select = this;
>
>     /*
>         do some stuff to select
>     */
>
>     select.find('option').each(function (ii) {
>         /* operate on each option */
>     });
>
> });
>
> Is this doable? If I remove iterating options (select.find
> ('option').each(...)), everything works fine of course, so nothing
> inside first loop is broken.

Reply via email to