I'm totally new to this, as I'm mainly a designer, so beware: I'm learning.
I'm trying to modify a WP plugin, to be able to clone a button via JQuery.
The original code is this:
SliderBehaviour.prototype.setupButtons = function (container, buttons) {
var _this = this;
this.$buttons = buttons;
this.$voteButton = this.$buttons.filter('button[value="vote"]');
this.$resultsButton = this.$buttons.filter('button[value="results"]');
this.$previousButton = jQuery("<button type="button" class="totalpoll-button totalpoll-buttons-slider-previous">" + this.poll.config['i18n']['Previous'] + "</button>");
this.$nextButton = jQuery("<button type="button" class="totalpoll-button totalpoll-buttons-slider-next">" + this.poll.config['i18n']['Next'] + "</button>");
container.prepend(this.$previousButton);
container.append(this.$nextButton);
After much reading and checking and trying, I added this line: container.append(this.$nextButton).clone(true, true).prependTo(".totalpoll-form");
after the last line of the previous code.
It does duplicate the buttons but they don't work. It actually shows all the buttons (previous, vote, next) instead of only showing "Next" as it does on the original set of buttons below the div.
So basically the buttons show and work below the container, I need a duplicate set of buttons ALSO on top of the container.
Buttons
Container
Buttons
I'm not sure if a code somewhere else on the plugin is preventing the buttons to work. I understood that using clone (true, true)
would duplicate the element and its functionality. I'm confused and sorry if I'm too new to this and I might be asking for help on something totally easy. Thanks in advance!
question from:
https://stackoverflow.com/questions/65921589/jquery-duplicate-a-button-on-the-same-div-container-so-i-have-2-sets-of-butto 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…