Greetings fellow meteorites!
In my entire life (when writing css id’s and classes that have multiple words) I have always used dashes (i.e. - ) as separation. For example position-description below
<input id="position-description" type="text" placeholder="back of the line" />
And who cares ???
Well when I target the form submit event in the client javascript, I can’t really access the value in the input by calling event.target.position-description because the - will cause an error in meteor.
The obvious workaround is to just camel-case the css id (i.e. positionDescription)
But before I abandon the css notation I have been using for the past 5 years, I was wondering if there was a workaround specifically using the event.target way (as opposed to jquery) ??
Hm right. If event.target is the form and “positionDescription” is the camelcased id, you could make the call event.target. positionDescription.value to access the value. … But is there a way to get it keep the css id notation of “position-description” ?
No. As I said, the actual id value (position-description in this case, but it doesn’t matter what it is) is not a property of the event method, so you cannot access it as you are describing.
In this case, event.target.id will be set to 'position-description', and event.target.value will contain the value of that DOM element.
As @shock says, if you are in any doubt, console.log the event object in your event handler.