How to move an element from inside to out side using jquery?

Ayaz Shah

I'm trying to move the anchor tag outside p element, currently it is inside the p element. Here is my html:

<div class="the_excerpt">
    <p>
        <a href="#">Learn More</a>
    </p>
</div>

I have tried append() function but it is not working. I don't want to insert new anchor element. I just want to move anchor element outside p element.

$('.the_excerpt').find('p').append($('.the_excerpt').find('a'));

Can any one please guide me how can I fix, I will appreciate. Thank You

Pranav C Balan

You are trying to append inside the p tag, since a is inside p it doesn't make any change for the markup. So change your code as follows

$('.the_excerpt').append($('.the_excerpt p a'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="the_excerpt">
    <p>
        <a href="#">Learn More</a>
    </p>
</div>


Or you need to use the appendTo()

$('.the_excerpt p a').appendTo('.the_excerpt');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="the_excerpt">
    <p>
        <a href="#">Learn More</a>
    </p>
</div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to make jQuery fadeIn/Out element smoothly move in and out of place

From Dev

How to move an div element up using jQuery?

From Dev

jQuery - Move element inside a sibling

From Dev

jQuery - How to move some tag element with text inside to closest div

From Dev

jquery move element to inside new element

From Dev

Jquery, using value of a variable inside a function, to set the value of another variable out side of that function

From Dev

Move a DOM element Using jQuery

From Dev

How to get value from inside <li> element and put it to image attribute tag using jQuery

From Dev

Jquery - Move image from element to element

From Dev

How to get data from MongoDB on client side using javascript/jQuery

From Dev

jQuery - how to assign click() to an element inside html that was loaded using load()

From Dev

how to find the file inside input element html using jquery

From Dev

How to automate with for loop inside array from a jquery element

From Dev

How can I move a div from top to bottom by using jQuery?

From Dev

How can I move a div from top to bottom by using jQuery?

From Dev

How to move items/buttons from one div to another using JQuery?

From Dev

How to move an element on the opposite side? html,css,js

From Dev

How to get every char from a text inside an element using a loop

From Dev

How to move a node element to be the first inside its parent element

From Dev

Fade in Fade out inside the bar using jquery

From Dev

move an element from one div to another div with animate effect on button click using html and jquery

From Dev

How to create New user using Asp.net mvc identity out side from Accountcontroller?

From Dev

How to create New user using Asp.net mvc identity out side from Accountcontroller?

From Dev

How do you move a div element in jquery

From Dev

Find next element out of parent using jQuery

From Dev

How to wrap a string using element from the list using jquery

From Dev

How to move away from a point inside a grid

From Dev

How to change CSS of child element <span> inside parent <div> element Using jQuery onclick event?

From Dev

How to break out from jQuery click event function from inside $.each

Related Related

  1. 1

    How to make jQuery fadeIn/Out element smoothly move in and out of place

  2. 2

    How to move an div element up using jQuery?

  3. 3

    jQuery - Move element inside a sibling

  4. 4

    jQuery - How to move some tag element with text inside to closest div

  5. 5

    jquery move element to inside new element

  6. 6

    Jquery, using value of a variable inside a function, to set the value of another variable out side of that function

  7. 7

    Move a DOM element Using jQuery

  8. 8

    How to get value from inside <li> element and put it to image attribute tag using jQuery

  9. 9

    Jquery - Move image from element to element

  10. 10

    How to get data from MongoDB on client side using javascript/jQuery

  11. 11

    jQuery - how to assign click() to an element inside html that was loaded using load()

  12. 12

    how to find the file inside input element html using jquery

  13. 13

    How to automate with for loop inside array from a jquery element

  14. 14

    How can I move a div from top to bottom by using jQuery?

  15. 15

    How can I move a div from top to bottom by using jQuery?

  16. 16

    How to move items/buttons from one div to another using JQuery?

  17. 17

    How to move an element on the opposite side? html,css,js

  18. 18

    How to get every char from a text inside an element using a loop

  19. 19

    How to move a node element to be the first inside its parent element

  20. 20

    Fade in Fade out inside the bar using jquery

  21. 21

    move an element from one div to another div with animate effect on button click using html and jquery

  22. 22

    How to create New user using Asp.net mvc identity out side from Accountcontroller?

  23. 23

    How to create New user using Asp.net mvc identity out side from Accountcontroller?

  24. 24

    How do you move a div element in jquery

  25. 25

    Find next element out of parent using jQuery

  26. 26

    How to wrap a string using element from the list using jquery

  27. 27

    How to move away from a point inside a grid

  28. 28

    How to change CSS of child element <span> inside parent <div> element Using jQuery onclick event?

  29. 29

    How to break out from jQuery click event function from inside $.each

HotTag

Archive