Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

javascript - Jquery Uncaught SyntaxError: Unexpected token } - Trying to pass guid as parameter

Hi I am trying to pass guid to a function but it gives me error,

Uncaught SyntaxError: Unexpected token }

var gg = "someGuid";     
var callFunction = "<tr class='MenuRow' onclick='myFunctionabc('" + gg + "')'></tr>"

function myFunctionabc(abcd){
    alert(abcd);
}

I am trying on Chrome, any clue ?

Edit

Sorry for some people who don't know what's GUID, its a number like this "0a6bb960-97c4-4099-8e0a-cc5cc81ed451"

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to escape stating and closing quotes of onclick=""

var callFunction = "<tr class='MenuRow' onclick="myFunctionabc('" + gg + "')"></tr>"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...