How can I change this here so that I click on a div with a certain ID or Class and open a dialog with a certain ID?
$('body').on('click', '#id01', function() {
var dlg = new DialogFx($('#itemDetails').get(0));
dlg.toggle();
});
In this case, I can only click in the div "#id01" to open the dialog with "#itemDetails";
But I want to create "itemDetails2" "itemDetails3" and open by clicking in differents divs with differents IDs in the HTML.
2
Answers
Replace the ID (in the selector spot, after event’s name) by a class name or a customized attribute (aka data-attribute).
Previously you must add the same class name to all related elements.
Using a data attribute you can target elements and use the value to determine what element to select.