Snake
Snake

Reputation: 337

Change the html of span through javascript

I am developing an asp.net web app in which I am using a span tag

<span id = "ptxtAgree" >  <%: data.Agree %></span>

and I want to update the span text through javascript and in script I am writing

  $("#ptxtAgree").text(msg);

If I am writing the empty span then its value is updated but by using this <%: %> it is not possible.

Sorry for poor English

regards

Upvotes: 0

Views: 346

Answers (1)

Sabari
Sabari

Reputation: 6335

To change the html inside the span using jQuery you can use :

$("#ptxtAgree").html(msg);

If you want to remove everything inside the span you can use:

$("#ptxtAgree").empty();

Hope this helps :)

Upvotes: 1

Related Questions