In an HTML I have for example:
<fieldset>
<div>
<h3 class="title title-line">Dados da conta</h3>
</div>
<div class="ch-form-row">
<label>Usuário</label>
<span>MEU-USUARIO</span>
<a class="smalla" href="https://myaccount.mercadolivre.com.br/profile/changeNickName">Modificar</a>
</div>
<div class="ch-form-row">
<label>E-mail</label>
<span>[email protected]</span>
<a class="smalla" href="https://myaccount.mercadolivre.com.br/profile/changeEmail">Modificar</a>
</div>
<div class="ch-form-row">
<label>Senha</label>
<span>**********</span>
<a class="smalla" href="https://accountrecovery.mercadolivre.com.br/accountrecovery/changePassword">Modificar</a>
</div>
</fieldset>
I need another page to capture the username and save it to a variable, the closest it can reach with jQuery Load()
was:
$( "#id-de-teste" ).load("https://myaccount.mercadolivre.com.br/profile .ch-form-row span:first", function(data, status){
username = $('#retorno_webtracker').html();
alert(username);
});
But I had 2 problems: The variable with the Username was also with the <span>
tags, and I do not want / need this value to appear on the page, I only need it in the variable to proceed with the script routine.
With jQuery Get()
I can "download" the page with the data I need, however I am not able to filter only the .ch-form-row class after the first
$.get("https://myaccount.mercadolivre.com.br/profile", function(data, status){
//alert("Data: " + data + "\nStatus: " + status);
//username = $('span',$('.ch-form-row')).html();
filtro = data.getElementsByClassName('ch-form-row');
console.log( filtro );
});