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
Post a Comment