Attr with Internet Explorer

0

I have an application where I click on the row of a table, jquery takes the id of the table row, assembles a URL and places it inside a

The problem is that I am not able to make the attr. run in IE, I already tested it on chrome and mozilla , it works normal, but I need it to work in IE

PS. The application has to run in IE, and in version 8 !!!

Table (comes from an external page via Ajax)

foreach ($retorno as $valor) {
            $html.= "<tr class='codFuncionario' codigo=".$valor['codigo'].">";
                $html.= "<td>".$valor['nome']."</td>";
                $html.= "<td>".$valor['drt']."</td>";
                $html.= "<td>".$valor['cpf']."</td>";
                $html.= "<td>".$valor['setor']."</td>";
                $html.= "<td>".$valor['cargo']."</td>";
                $html.= "<td>".$valor['turno']."</td>";
            $html.= "</tr>";
        }
echo $html;

Script

$(document).on("click", ".codFuncionario", function(e){
    e.preventDefault;
    var codFuncionario = $(this).closest('tr').attr('codigo');
    //alert(codFuncionario);
    $(".a_registrar_digital").attr('href', 'registrar_digital.php?codigo='+codFuncionario);
});

Html

<a href'' class='a_registrar_difital' target='end_font' >Click Aqui</a>

Someone there has already faced the same problem as me and has a solution ???

    
asked by anonymous 29.09.2014 / 14:07

2 answers

1

I do not have Internet Explorer 8 to try to reproduce the problem, but I leave some tips that may be behind the problem.

Your HTML has some errors, although I find copy-paste errors for Stack Overflow. However, please confirm that they are present in the original.

<a href'' class='a_registrar_difital' target='end_font' >Click Aqui</a>

= is missing in attribute href , and class has difital , instead of digital that jQuery looks for.

There is a question in the international OS where the problem with IE8 was the developer's tool needs to be refreshed manually to show the changes in the DOM document.

There is another issue in the international OS where we recommend using HREF instead of href , not jQuery. I think it has to do with IE taking the path as absolute or relative to the current domain.

In the latter case, consider changing the property without jQuery, as an example.

$(document).on("click", ".codFuncionario", function(e) {
    e.preventDefault;
    var codFuncionario = $(this).closest('tr').attr('codigo');
    var caminho = 'registrar_digital.php?codigo=' + codFuncionario;
    var as = $(".a_registrar_digital");
    var i = as.length;
    while (i--) {
        as[i].href = caminho;
    }
});
    
29.09.2014 / 18:04
0

I use with attr the data- * attributes in IE all the time, I've never had a problem. Here is an online version , just tested in IE6, IE7 and IE9. It does not have my IE8 box accessible, but then again, I've never had a problem.

  

Source link

    
29.09.2014 / 14:51