I need to get the ID of one of the elements inside a combobox

Asked

Viewed 64 times

0

I have the following X path : //*[@id="selectDashboard"] inside that has some ID’s that would be certain Dashboard s, how do I catch these guys inside the Xpath? Dashboard HTML code with an ID inside it: and also consider that this is a combobox

<option value="8" title="Overview of application activity on your network" lastviewed="1510593168860" dashboarddesc="Overview of application activity on your network" isshared="false" selected="">Application Overview</option>

2 answers

0

To catch an element through the xpath using the id just do the following way

//option[@id="iddesejado"]

if you still want to filter more Window you can use

//option[@id="iddesejado"][@value="checked"]

Voce can add as many parameters as you want .

  • from what I understand, the friend does not want to take the option for her id, he wants the ID of the option he selected.

  • Thanks friend worked out!

0

In the example below Voce handles the ID attribute of the selected option.

$('#exemplo').change(function() {
    var valor = this.value;
    var id= $(this).find(':selected').attr('id');
    console.log(valor, id);
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.