I don't understand how the variable works in 11/14


#1



https://www.codecademy.com/courses/web-beginner-en-v6phg/2/2?curriculum_id=50a3fad8c7a770b5fd0007a1#


I passed the exercise, but I don't feel like I understand how this is happening. Can anybody explain it to me?


var toAdd = $('input[name=checkListItem]').val()


#2

Hi @ragingamer333,

It's a CSS attribute selector. In this case, we have something like this:

<input type="text" name="checkListItem">

Since there's no way by default to select that specific element using CSS, you can use a CSS attribute selector like so:

input[name="checkListItem"] {
  /* styles */
}

You can see more information here:
https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors :slight_smile:


#3

Thank you, I understand it now :smiley:


#4

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.