-2

Basically, the code creates a "scheduler" of sorts using JS for an assignment. I spent hours troubleshooting why the code below wasn't correctly saving information to local storage. I was able to isolate the error to a specific function within my code.

Once I did that, then I went down each line of code and tried everything to see what would fix the error. Turns out, adding a space before textarea in let eventEl = $("#" + rowId + "textarea"); fixed it for some reason.

In other words, let eventEl = $("#" + rowId + " textarea"); works fine, but the previous one doesn't.

Can anyone help explain why?

notelon
  • 1
  • 1

1 Answers1

1

A space is the descendant combinator in CSS. If you did not add the space, you would be looking for an element with the id of rowId concatenated with "textarea" rather than a textarea contained inside the element with id of rowId.

The descendant combinator — typically represented by a single space (" ") character — combines two selectors such that elements matched by the second selector are selected if they have an ancestor (parent, parent's parent, parent's parent's parent, etc) element matching the first selector. Selectors that utilize a descendant combinator are called descendant selectors.

Unmitigated
  • 76,500
  • 11
  • 62
  • 80