Javascript and CSS, using dashes -


I am starting to learn some javascript and understand that dash is not allowed when giving the identifier name, although the ID in the CSS And it is common to use dashes for classes.

Does the use of dashes in CSS interfere with JavaScript interaction in any way? For example, if I wanted to use getElementByID ("css-dash-name") I have tried to use getElementByID with some examples as a name for a devi ID and getElementByID, but it worked I'm not sure that this is the case in all other references.

In the id (or the name of the class, if there is a dash and underscores), there will be no negative effect, So it is safe to use it, you can just not do something like this:

  var element = document.getElementByID ('css-dash-name');  

The error mentioned above is causing the error because the variable in that variable is specifying the element from which you are specifying.

The following will be okay though because there is no dash in the variable:

  var someElement = document.getElementByID ('css-dash-name');  

This naming limitation is only for javascript variables.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -