I have this piece of code in JavaScript (jQuery):
$("<a />").html("?").attr({
    href: "javascript:void();",
    class: "CorrentTooltip",
    title: "Explain!"
});
What are the alternatives to escape reserved word class?
ps.: The option class is causing a mess with my Javascript Parser in my IDE (Visual Studio) due to conflict with keyword class. So, the JS Parser says that there's a lot of syntax errors after this point. I can't collapse code blocks. It continues functional, but ugly.
Javascript uses '\' (backslash) in front as an escape character. To print quotes, using escape characters we have two options: For single quotes: \' (backslash followed by single quote) For double quotes: \” (backslash followed by double quotes)
JavaScript escape() The escape() function is deprecated. Use encodeURI() or encodeURIComponent() instead.
To use a special character as a regular one, prepend it with a backslash: \. . That's also called “escaping a character”.
You can escape it by enclosing it using '' or "" 
$("<a />").html("?").attr({
    href: "javascript:void();",
    'class': "CorrentTooltip",
    title: "Explain!"
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With