Reputation: 20078
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;
}
);
});
Upvotes: 9
Views: 54988
Reputation: 832
if your value is a pure text (like 'test') you could use the text() method as well. like this:
$('#numberOf').text(data); Or $('#numberOf').html(data);
Both are working fine.
Upvotes: 0
Reputation: 42011
Text: http://api.jquery.com/text/
$("#numberOf").text(data);
Html: http://api.jquery.com/html/
$("#numberOf").html(data);
Upvotes: 21
Reputation: 9503
Set the text property...
$("#btn").click(function (event) {
$.getJSON('http://host/myServiceImpl.svc/GetCount?method=?', { id '1' },
function (data) {
alert(data);
$("#numberOf").text(data);
});
});
Upvotes: 1
Reputation: 186562
^ 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)
Upvotes: 14