Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/05/2015, 15:44
CHAEEZ
 
Fecha de Ingreso: julio-2013
Ubicación: Temuco
Mensajes: 48
Antigüedad: 10 años, 9 meses
Puntos: 0
Pregunta Capturar valor de TD en tabla HTML

En internet encontre este codigo que sirve para capturar el valor de una celda en una tabla html, pero no funciona y no tengo idea de por que. He probado todas las combinaciones posibles.

De hecho en esta pagina funciona perfectamente

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2. //<!CDATA[
  3.     $(document).on("ready", function(){                  
  4.       $("#tablaBuscador table tr td").click(function() {
  5.         var celda = $(this);
  6.         alert(celda.html());
  7.       });
  8.     });
  9. //]]>
  10. </script>


Este es el formato de mi tabla.
Código HTML:
Ver original
  1. <div id="tablaBuscador" class="table-responsive" style=" height: 384px;overflow: auto; margin-top: 43px;" >
  2.         <table class="table table-hover" style="margin-left: 25px;width: 96%; " id="buscadorProd">
  3.                   <thead style="position: absolute;  background-color: white;   margin-top: -21px;">
  4.                 <tr>
  5.                     <th style="width:10px; padding-right: 74px;">CÓDIGO</th>
  6.                         <th style="width: 492px;">PRODUCTO</th>
  7.                     <th style="width: 41px;padding-right: 11px;">U.M</th>      
  8.                     <th style="width: 66px;padding-left: 19px;">PRECIO</th>
  9.                     <th style="width: 109px;padding-left: 27px;">STOCK</th>
  10.                 </tr>
  11.             </thead>
  12.             <tbody id="buscacodigo">
  13.             </tbody>
  14.         </table>
  15. </div>


Las filas las creo dinamicamente mediante ajax. Espero me puedan ayudar, estoy trabado en esto que es muy importante en mi desarrollo. >.<

Última edición por CHAEEZ; 26/05/2015 a las 15:57