Reputation: 1515
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!
Upvotes: 0
Views: 97
Reputation: 550
You can select required element with $('div[name=uop-modal]')
jQuery selector.
Upvotes: 1