javascript - Why can't I use a variable as a ID selector? -


sorry being jquery noob i'm not understanding why can't place variable selector name? if alert works fine, not when try modify contents of id:

'success': function () {         var varpk = $(this).editable().data('pk');         //alert('#test' + varpk);         var spanid = '#test' + varpk;         //alert(spanid);         $(spanid).html(varpk); } 

if sure id exists, should work form code there.

see working example here:

settimeout(function() {     var id = '#' + 'asdf';     $(id).html('fdsa'); }, 2000); 

ps: believe $(this) not returning think should, unless want target context of callback.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -