0

Is there a way to / How would you select elements by class defined from input from a text field?

The example is:

<input type="text" id="search" />
<div class="abc"></div>
<div class="def"></div>
<div class="def"></div>
<div class="abc"></div>

Pseudo-jquery:

$("#search").blur(function() {
    $('.class-of-what-was-typed-in-search-box').addClass(".highlight");
});
nikmav
  • 375
  • 1
  • 3
  • 12

1 Answers1

1

Use:

$('.'+$("#search").val())
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231