简体   繁体   中英

Passing parameter to a javascript function, which contains a '-'

I am trying to pass a parameter as text which contains multiple ' - '.

eg. 4f5ff225-70bc-4970-a12d-483beb066c47

But when i pass it.. i get nothing in result. I guess ' - ' is creating problem. Is there any way to pass the above example as it is to the javascript function.

I guess, your code looks something like this:

 foo(4f5ff225-70bc-4970-a12d-483beb066c47)

This is not going to work and there should be some errors in the console.

Pass it as a string (because that's what it is).

 var foo = function(s) {
   alert(s);
 }

 foo('4f5ff225-70bc-4970-a12d-483beb066c47')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM