Created
March 13, 2017 10:37
-
-
Save aosteraas/e3a1e4506a74c9a4086b60939e40030f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I think the best way to show how the choice will influence what you do is in html | |
// Normally when writing HTML you would use double quotes for whatever classes/attributes you apply | |
// but here, in JS, we are starting the string with double quotes so we *must* use single quotes instead | |
var myElement = "<div class='class-something'></div>"; | |
var myClass = "snd-nds"; | |
// If you want to use a variable as the class name you need to use single quotes like we did before but then use | |
// concatenation to join it together | |
// ** ** | |
var anotherElement = "<div class='" + myClass + "'></div>"; | |
// The inverse will also work | |
var andAnotherOne = '<div class="' + myClass + '"></div>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment