Adding a Target
In client-side coding, it is fairly common to want to mark a particular DOM element as being of interest to the code. Typically this means either you are reading the DOM elementâs state to determine what to do or you are changing the DOM elementâs state as a result of some other event. In our case, itâs the latter: we want to add the DOM class hidden to an element to hide it, and eventually we want to change the text of the button itself.
In a world without a framework, or in jQuery world, we would identify these elements using a DOM ID or DOM class. However, because those DOM attributes are also used to manage CSS styling, it can be confusing as to what DOM ID or class elements are styling and which are used by JavaScript. ...
Get Modern Front-End Development for Rails, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.