javascript - why is my string no string anymore after give it to a function? -


solved: read edit below

first of create string this:

var child_id = "childid"+this.id; alert(child_id); 

the alert shows correct string. this.id string , made temp variable , put again string (var tmp_child_id = child_id.tostring()) sure string.

after give string function gotonextnode href link this:

this.svgimagediv.innerhtml = '<a href="javascript:gotonextnode('+child_id+')"><img src="img/transparent.png"/></a> 

in function gotonextnode fire alert @ first , dont show string alert above, says "[object htmldivelement]".

function gotonextnode(childid){    alert(childid); } 

what happend string , how transport string correctly?

edit: solved: when var child_id = this.id; instead of var child_id = "childid"+this.id; , put "childid" string id in function gotonextnode() works. dont ask me why behave this, dont it...

end edit

you forgot quotes argument inside brackets:

this.svgimagediv.innerhtml = '<a href="javascript:gotonextnode(`'+child_id+'`)"><img src="img/transparent.png"/></a>'; 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -