1

I am working with Angular and jQuery

I have div "A", pulling content via angular

<div class="a">
   <p ng-repeat="banana in bananas">{{banana}}</p>
</div>

I have ul class "B"

<ul class="b">
  <li>content 1</li>
  <li>content 2</li>
  <li>content 3</li>
<ul>

When any of the li inside "B" is clicked insert that li in .accordion

//this works fine    
$(".b li").click(function () {
   $(this).clone().appendTo(".accordion");
 });

The problem is when I want to do the same thing for div "A"... div "A" is inserted on the LAST appended li

jQuery accordion div, its empty,

<div class="accordion">
</div>

and am trying to create a NEW instance of div "A" everytime a li is clicked then must be inserted as a NEW child of the accordion so that it can work independently

1 Answer 1

1

class "A" must be created within jQuery, then inserted

myVar = $("<div class="a"><p ng-repeat="banana in bananas">{{banana}}</p></div>");


$(".b li").click(function () {
   $(this).clone().append(myVar).appendTo(".accordion");
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.