How to click on a TD and get the value of another TD hide?

0

One with 4, being a hide. Is there any way I can click on any and get the value of hide and send to my controller? This way I get the value of being clicked.

$('#nmUsuario').on("dblclick", '.clique', function () {
    CarregaDados($(this).text());
})

function CarregaDados(ajaxParameter) {

    $.ajax({

        url: '/CadastroAcesso/CarregaDadosPagina',
        datatype: 'json',
        contentType: 'application/json;charset=utf-8',
        type: 'POST',
        data: JSON.stringify({ _nivel: ajaxParameter }),
        success: function (data) {
        },
        error: function (error) {
        }
    })
}

Now, as I click on this <TD> and get the value of what hide is. I think I should get the value of <TR> , make one each and just load the value of <TD> hide, but I'm getting caught up in it. How do I go through <TR> to get the <TD> I want.

I've been gone for a while now and came back to finish what I started. Still giving an error. It does not enter into the success of ajax , on the contrary, it enters the function Error of ajax .

    
asked by anonymous 28.10.2014 / 13:05

3 answers

0

I solved it like this:

$(this).parent().find(".idusuario").text()
    
28.10.2014 / 20:41
0

Let's say your hidden TD has a name:

<td class="escondida" style="display:none;">Valor escondido</td>

Then just change your code to:

$('#nmUsuario').on("dblclick", '.clique', function () {
    CarregaDados($(this).find(".escondida").text());
});

I did not test in jfiddle but if it does not work take a look at jquery's find command, it will solve for you.

    
28.10.2014 / 13:15
0

Use the selector: not (: visible

var conteudoHtmlTd = $("td:not(:visible)").html(); //se quiser o html da td
var conteudoTextoTd = $("td:not(:visible)").text(); //se quiser so o texto da td

If you want to get a td hide that is on the same line as another td you clicked it would look like this:

$(document).on("click", "td", function(){
    var conteudoHtmlTd = $(this).parent().find("td:not(:visible)").html();
});

If it has a class it's even easier:

$(document).on("click", "td", function(){
    var conteudoHtmlTd = $(this).parent().find(".classe").html();
});
    
31.10.2014 / 20:58