Saturday, 15 September 2012

javascript - passing value with special character to function onclick event -


To understand my head, why can not I pass a value with special characters for the function. The value on the onclick event is ok, but the special character has been removed for this value in the function

variable value: app \ xpto

Getting into function: appx

How can I get the full value with specific characters?

Can someone give me a hand?

  onclick = "changeUserPictureInParent ('http: // mysite? F=@p.num'); ToUser (\ '@ ViewBag.ID.ToString () \', \ '@ ViewBag .temp ToString () \ ', \' @ html.raw (p.Name) \ '); "& gt; Note: Using the razor engine,   

OK I got a solution to my problem.

Use the onclick event instead, I use the jquery .click event.

Using the data variable as my variable value and then on click I select the value from my data attribute.

This way.

  & lt; Div class = "change" data-attr = "@ html.raw (name)" & gt; & Lt; / Div & gt; $ ("Change"). Click (function () {var a = $ (this) .attr ("username");});  

No comments:

Post a Comment