Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set div value

Tags:

jquery

How do I set the value/text of a 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;
    }
  );
});
like image 708
Nick Kahn Avatar asked Nov 23 '10 00:11

Nick Kahn


3 Answers

Text: http://api.jquery.com/text/

$("#numberOf").text(data);

Html: http://api.jquery.com/html/

$("#numberOf").html(data);
like image 56
Dean Taylor Avatar answered Oct 13 '22 00:10

Dean Taylor


  • http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=jquery+text+div
  • http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=how+do+i+set+the+value/text+of+a+div%3F

^ Google gives you everything you need. I would suggest googling before asking.

So to answer, you'd want

$('#numberOf').text(data) 

or

$('#numberOf').html(data)
like image 32
meder omuraliev Avatar answered Oct 12 '22 22:10

meder omuraliev


or

$('#numberOf').html(data);
like image 24
craigmoliver Avatar answered Oct 12 '22 23:10

craigmoliver