2010-11-23 12 views
9

¿Cómo configuro el valor/texto de div?Cómo establecer el valor div

<div id="numberOf"></div> 

$("#btn").click(function (event) { 
    $.getJSON('http://host/myServiceImpl.svc/GetCount?method=?', 
    { id '1' }, 
    function (data) { 
     alert(data); 
     $("#numberOf").val = data; 
    } 
); 
}); 

Respuesta

1

Establecer la propiedad de texto ...

$("#btn").click(function (event) { 
       $.getJSON('http://host/myServiceImpl.svc/GetCount?method=?', { id '1' }, 
       function (data) { 
        alert(data); 
        $("#numberOf").text(data); 

       }); 
      }); 
0

si su valor es un texto puro (como 'prueba') se puede utilizar el método de texto() también. de esta manera:

$('#numberOf').text(data); Or $('#numberOf').html(data); 

Ambos están trabajando bien.

Cuestiones relacionadas