Assign ids to buttons

How can I add ids to the buttons which are created like the following in jQuery dialog. Here’s a code snippet and here is my complete code in JSFiddle

let buttons = {};

  buttons["Login next suggested value " + additionalValue] = function() {

  buttons["Login case number of your choice"] = function() {

  buttons["Cancel button"] = function() {

I would like to have button id for first buttons as #suggestedValue, second button as #yourChoice and for the third button as #cancelChoice

I’m not super familiar with JQuery, but perhaps try

$(selector).attr('id', 'the-id-you-want-to-use')

You would need to change your code up somewhat to move away from the Object invocation of buttons to the Array invocation.

  let buttons = [
      {"text": "Login next suggested value " + additionalValue,
       "id": "suggestedValue",
       "click": function() { $(this).dialog("close"); }
1 Like