S
S
Sergey Weblife2016-09-25 15:24:49
JavaScript
Sergey Weblife, 2016-09-25 15:24:49

How to use the input field to call blocks by id?

Guys, welcome everyone;) I have a question, is it possible to call a block

using the input field of a text query? Let's say, somehow set an id for the block and for this id in the script set several possible variations of the text query, let's say: " Block text, text block, text " and when you enter " block text " or other variation in the input , it would be called this block, which in principle is in the markup, is only hidden .. and if it weren’t in the markup, but done using ajax, it would be generally cool, is it possible to do it and how? Many thanks in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
teotlu, 2016-09-25
@weblife-design

Did I understand correctly what you need?
codepen.io/teotlu/pen/NRpoNw

T
T_y_l_e_r, 2016-09-25
@T_y_l_e_r

var elems=doc_elem.getElementsByTagName('input');
    for(var i=0; i<elems.length; i++){
      if(elems[i].value.indexOf("блок текст") > -1 && elems[i].value.indexOf("текст") > -1) {
//
      }
    }

if(str.search( /текст/i ) !=-1) {

}
if(/текст/i.test(str)) {

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question