Ive got button that is closing bootstrap modal as below:
<button id="back_offer_button" type="button" class="btn btn-default" data-dismiss="modal" data-toggle="modal" data-target="#addOffer">Go back</button>
I want to be able to dynamic change data-target via vanilla javascript to different location:
For example now is
data-target="#addOffer"
I want to change it to
data-target="#addDifferentOffer"
So I tried to get this button:
var backOfferButton = document.getElementById('back_offer_button');
And then:
backOfferButton.data-target = "#addDifferentOffer" <?>
This of course doesn't work. How should it be written correctly?
backOfferButton.setAttribute('data-target', '#addDifferentOffer')
? – Implantation