javascript - Getting error when appending to documentFragment -


i'm getting error when creating document fragment, appending elements , returning fragment. i've used document fragments in past (abused them way beyond example) , have never run in error. in developer console lists source of error:

fragment.appendchild($balancenumber, $balancesign); 

error

uncaught notfounderror: attempt made reference node in context not exist.

function

var constructbalancefragment = function(balance) {     var $balancenumber, $balancesign, fragment, sign;     fragment = document.createdocumentfragment();     $balancenumber = $('<span class="balance_number"></span>');     $balancesign = $('<span class="balance_sign"></span>');     if (balance > 0) {       sign = "+";       $balancesign.addclass("positive_number");     } else if (balance < 0) {       sign = "-";       $balancesign.addclass("negative_number");     } else {       sign = "";     }     $balancenumber.text(balance);     $balancesign.text(sign);     fragment.appendchild($balancenumber, $balancesign);     return fragment; 

edit

i have tried , still got same error before asks

fragment.appendchild($balancenumber); fragment.appendchild($balancesign); 

this closer original , seems work, keeping in spirit of jquery:

$(fragment).append($balancenumber, $balancesign); 

http://jsfiddle.net/tfdxd/1/


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -