最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

asp.net - Moving button element to different div(parent) using JavaScript - Stack Overflow

matteradmin8PV0评论

I have a button on a aspx page should be positioned on table for one criteria and for other it should be positioned on different div (I dont have the access to code behind for programmatic adding ) all i have to do is though javascript what would be the best way to move the button position?

<div id= "main">
    <table>
        <tr><td id="loginsbtbtn"></td><tr>
    <table>
    <div id="cbtn">
        <asp:Button ID="btnSubmit"  BackColor="#b5c7de" runat="server" Text='continue' /> 
    </div>
</div>

Thanks in advance

I have a button on a aspx page should be positioned on table for one criteria and for other it should be positioned on different div (I dont have the access to code behind for programmatic adding ) all i have to do is though javascript what would be the best way to move the button position?

<div id= "main">
    <table>
        <tr><td id="loginsbtbtn"></td><tr>
    <table>
    <div id="cbtn">
        <asp:Button ID="btnSubmit"  BackColor="#b5c7de" runat="server" Text='continue' /> 
    </div>
</div>

Thanks in advance

Share Improve this question edited Dec 21, 2010 at 19:18 user113716 323k64 gold badges453 silver badges441 bronze badges asked Dec 21, 2010 at 18:26 GrasshopperGrasshopper 1,8186 gold badges29 silver badges49 bronze badges 2
  • can you give us a code snipplet – qwertymk Commented Dec 21, 2010 at 18:30
  • <div id= "main"> <table> <tr> <td id="loginsbtbtn"> </td> <tr> <table> <div id="cbtn"> <asp:Button ID="btnSubmit" BackColor="#b5c7de" runat="server" Text='continue' /> </div> </div> – Grasshopper Commented Dec 21, 2010 at 18:43
Add a ment  | 

1 Answer 1

Reset to default 5

Using jQuery, do this:

$('#myButton').appendTo('#someDiv');

Without jQuery, do this:

document.getElementById('someDiv').appendChild(document.getElementById('myButton'));

This assumes the targeted elements have ID attributes. Impossible to give an exact solution without any HTML in the question.

Post a comment

comment list (0)

  1. No comments so far