Search code examples
javascriptonclickspecial-characters

Special characters in javascript onClick paramerters


I have a javascript onclick function. I am passing certain values which has special characters inside onclick.

<a href="#" onclick="editLocation(34:B1:F7:D5:BB:52)">click</a>

which gives me an error

enter image description here

How do i pass all the value inside onclick.. I don't want to ignore special character. I must pass the complete value 34:B1:F7:D5:BB:52


Solution

  • Add single quotes, like this

    <a href="#" onclick="editLocation('34:B1:F7:D5:BB:52')">click</a>
    

    Example