Passionate generalist conquering the web one project at a time. Whether authoring libraries for node, JS, PHP, or Rust, I am always on the lookout for better solutions to common problems.
Location
USA
Work
Lead Developer & Co-founder at corpscrypt, CTO at REtech
Uff. This would be a lengthy discussion as you can of course write nicely. The emphasis was in "invites [... writing terrible code]".
On a high level, DOM interactions are normally done by directly using the selector, usually wrapping the same elements over and over again.
$("#btn").click(function (){
$("#btn").html("resend");
// Or
$(this).html("resend");
});
Both of these common options are strange as in the first version we create a new instance while the second one takes the this object which does not inherit the jQuery prototypes and therefore needs to be wrapped into a jQuery element again. This is especially weird considering that most listeners are shorthands for .on(event, function(event){}), which would hand you the native source element.
The usual result is either assigning many variables globally or repeating selectors until the doctors come.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Uff. This would be a lengthy discussion as you can of course write nicely. The emphasis was in "invites [... writing terrible code]".
On a high level, DOM interactions are normally done by directly using the selector, usually wrapping the same elements over and over again.
Both of these common options are strange as in the first version we create a new instance while the second one takes the this object which does not inherit the jQuery prototypes and therefore needs to be wrapped into a jQuery element again. This is especially weird considering that most listeners are shorthands for .on(event, function(event){}), which would hand you the native source element.
The usual result is either assigning many variables globally or repeating selectors until the doctors come.