How (can one?) can I open a modal using jQuery or JavaScript, using the HTML element's name attribute value, instead of using the modal id? (I have the same modal id so I don't have to duplicating my css)
I was thinking something like this would do the trick:
<div id="product-description-modal" name="uop-modal" role="dialog" class="modal"></div>
<div id="product-description-modal" name="payu-modal" role="dialog" class="modal"></div>
My jQuery method to open the specific modal:
onShowModal() {
if (this.showPayAsYouUseModal === true) {
$('div[name]="payu-modal"').modal('show');
} else {
$('div[name]="uop-modal"').modal('show');
}
}
But I have had no luck so far. What am I missing?
Thank you in advance!
$('div[name=uop-modal]')should do the trick. (Also, don't use the sameidmore than once; as "id" suggests it's supposed to be unique. Use a class instead.)