.addClass doesn't work

.addClass doesn't work
0.0 0



It should change the background color of the div with the search icon when clicked, but it does not.

I applied proper CSS and jquery and don’t know what’s the cause. I thought it might be codepen’s faulty environment, but it’s not - it’s probably me :smiley:

I transferred it to JSbin, without a success:

Please take a look and help me.


Hey, 2 things are wrong.

  • You forgot a “}”
    input[type="text"]:focus { border-color: rgba(121, 66, 16, 0.9); box-shadow: 0 1px 1px rgba(39, 33, 33, 0.8) inset, 0 0 8px rgba(152, 66, 16, 0.3); outline: 0 none;
  • In your JS you tried to access value
    var mainLink = "https://en.wikipedia.org/w/api.php?action=query&format=json&generator=search&gsrnamespace=0&gsrlimit=10&prop=extracts|pageimages&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&callback=JSON_CALLBACK&gsrsearch=" + value;
    But this variable is not yet declared. It is only declared at the keyup event. So change that to:
    var value = ""; $("#usr").keyup(function() { value = $( this ).val(); });
    Or just put the var mainLink = ....; in there as well. So that value is only accessed when it is declared and has a value.