How to set a value for a <span>
tag using jQuery…
For example…
Below is my <span>
tag:
<span id="submittername"></span>
In my jQuery code:
jQuery.noConflict(); jQuery(document).ready(function($){ var invitee = $.ajax({ type: "GET", url: "http://localhost/FormBuilder/index.php/reports/getInvitee/<?=$submitterid;?>", async: false }).responseText; var invitee_email=eval('(' + invitee + ')'); var submitter_name=$.map(invitee_email.invites, function(j){ return j.submitter; }); alert(submitter_name); // alerts correctly $("#submittername").text(submitter_name); //but here it is not working WHy so?????? });
jQuery: Set a value in a span Set a value in a span using jQuery. JavaScript Code: $(document). ready(function(){ $('#button1').
jQuery val() Method The val() method returns or sets the value attribute of the selected elements. When used to return value: This method returns the value of the value attribute of the FIRST matched element.
a span doesn't have a value attribute.
You can do:
$("#submittername").text("testing");
or
$("#submittername").html("testing <b>1 2 3</b>");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With