Creating And Copy/duplicating A Select/option List Menu With Javascript March 08, 2024 Post a Comment I have a select list menu: 12Solution 1: I can't test in IE right now, but try using .cloneNode() instead to create the new element.var selectt = document.getElementById("select1").cloneNode(true); selectt.setAttribute("name", "select"+counter); selectt.setAttribute("id", "select"+counter); selectt.onchange = (function( cntr ) { returnfunction() { sellcalculate(cntr); }; })( counter ); cell3.appendChild(selectt); CopyThe true argument passed to .cloneNode makes it a deep clone (all descendants).Also, I assumed you want the onchange handler to reference the current value of counter instead of a potentially different future value. As such, I scoped the current value using a new function invocation. Now whatever the value of counter is when this code runs will be the value passed to sellcalculate().Solution 2: You can use jQuery .clone() like this:$('#select1').clone().attr({'id':'select'+counter, 'name':'select'+counter}).appendTo('cell3Selector'); CopyTest page here. Share Post a Comment for "Creating And Copy/duplicating A Select/option List Menu With Javascript" Top Question Buttons Centered Over Canvas I have 4 overlapping canvases (acting as layers) positioned… Batch Conversion Of Docx To Clean HTML I'm starting to wonder if this is even possible. I'… Transfer A Mousewheel/scroll Event From One Div To Another I would like to know if it's possible and how to transf… Selecting Text Between Is it possible to select text between tags? I am working w… Prevent Grid Area From Expanding Causing Whole Page To Scroll I'm using the following grid layout: grid-template-colu… How To Limit The HTML Table Records In Each Page I am populating a table in my jsp which has more than 20 re… How To Limit The Html Table Records In Each Page I am populating a table in my jsp which has more than 20 re… Concatenate Parts Of Two Or More Webm Video Blobs Is it possible to to concatenate parts of two or more video… How To Play GSM Files In HTML5 I would like to play a GSM audio file within my HTML5 page … JQuery CSS - Slider Swipe Animation UPDATE: Updated the code and added a better example to clea… December 2024 (1) November 2024 (36) October 2024 (47) September 2024 (20) August 2024 (202) July 2024 (183) June 2024 (411) May 2024 (686) April 2024 (466) March 2024 (819) February 2024 (907) January 2024 (761) December 2023 (842) November 2023 (357) October 2023 (583) September 2023 (280) August 2023 (317) July 2023 (276) June 2023 (343) May 2023 (211) April 2023 (141) March 2023 (141) February 2023 (168) January 2023 (258) December 2022 (118) November 2022 (231) October 2022 (829) September 2022 (165) August 2022 (299) July 2022 (90) Menu Halaman Statis Beranda © 2022 - Html5 Playground