javascript - Adding a div element to another part of the website when clicking a button -


i'm trying code jquery script adds functionality button. when click button (ex: settings), want add specific text (ex: settings), different div (the div predefined css rules), how google chrome tab works.

$(document).ready(function() {     var wbuttons = document.getelementbyid('#wrapper');     $(".buttonsettings").click(function() {         var domelement = $('<span>settings</span>').appendto(wbuttons);         $(this).after(domelement);     }); }); 

the code works partially, won't append #wrapper, under .buttonsettings div. should mention have predefined number of tabs (max 6).

thank you!

if want append html string element, use jquery appendto() method this.

$("button").click(function() {       $("<span>span content</span>").appendto("#wrapper");  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <button>append</button>  <br/><br/>  <div id="wrapper">wrapper content</div>


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -