Skip to main content

how to set a value for a span using JQuery



How to set a value for a span using JQuery..





For example… Below is my span







<span id="submittername"></span>







in my JQuery code…







<script type="text/javascript">

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??????

});





Source: Tips4all

Comments

  1. You can do:

    $("#submittername").text("testing");


    or

    $("#submittername").html("testing <b>1 2 3</b>");

    ReplyDelete
  2. You're looking for the wrong selector id:

    $("#submitter").text(submitter_name);


    should be

    $("#submittername").text(submitter_name);

    ReplyDelete
  3. You are using jQuery(document).ready(function($) {} means here you are using jQuery instead of $. So to resolve your issue use following code.

    jQuery("#submittername").text(submitter_name);


    This will resolve your problem.

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?