3 Replies Latest reply on May 27, 2015 5:09 AM by resdesign

    Accessing element in nested div

    mads18950258 Level 1

      Hi

      i got a problem accessing and changing an element within a nested div (im not using symbols only "groups" (divs))

       

      ex. how do i access a text label within a nested div?

      row1 -> item1 -> textLabel

       

      i tried .....

      .$("row1").$("item1").$("textLabel").something

      .$("row1 item1 textLabel).something

      .getSymbol("row1").getSymbol("item1").$("textLabel").something

       

      but all without any result ???, yes i would put a class on each of my items, but that'll be fairly silly with alot of items .

       

      any suggestions ?

        • 1. Re: Accessing element in nested div
          seano2o7 Level 3

          Access it like normal, if an item in a group is called item1

           

          then sym.$("item1").hide();

          • 2. Re: Accessing element in nested div
            mads18950258 Level 1

            i need something more precise, for every row there will be an item called 1, in my project it's important i only manipulate ex. item 1 in row 5... therefore i need something like $("row5").$("item1")... but this won't work.

            currently i have nested everything into symbols instead, it works but its not an optimal solution for my problem.

            • 3. Re: Accessing element in nested div
              resdesign Adobe Community Professional & MVP

              Hi there,

              if you have group div and jquery, you can use

              Example - group div is called buttons and has a number of elements in it.

              var buttons = sym.$("buttons").children();    

               

              $.each(buttons,function(i){

                $(this).on("click", function(){

                //code here  could be about changing an image on the click event - 'image' is a png file  - I added  mapArea1.png to the stage and change the name to image. Then I changed from div to img in the property panel.

              sym.$("image").animate({"opacity":1.00},700).attr('src',"images/mapArea"+[i]+".png");

                });

               

              if you wanted to change something on the children themselves, you would use $(this)

              for example to change the color and opacity of the children elements  of buttons on the click event add the following:

               

              $(this).css({'background-color':'red', 'opacity':0.5});

               

              Hope this help but I am not sure since I do not know what you are actually doing.

              1 person found this helpful