I wrote this code:

<div id='avt' align='center'> <div id='session_true'> код </div> <div id='session_false'> код </div> </div> 

The question is how to correctly select session_false and session_true in jQuery ? Thank you in advance.

  • Immediately both elements? But don't the standard selectors work anymore? var elems = $ ('# session_true, #session_false'); - Deonis
  • I need to select one, but for some reason I don’t get it .. - oOKomarOo
  • Give a link to the page. - Zhukov Roman
  • I work on LAN. - oOKomarOo
  • And what about the console, without errors? - Zhukov Roman

4 answers 4

If I understood correctly, the following code will hide the session_true block and show the session_false block, for example:

 $('#session_true').hide(); $('#session_false').show(); 

I advise you to start learning the basics of jQuery (but first javascript).

  • I know that this is the case, I just don’t want to work .. - oOKomarOo
  • So you have a mistake somewhere else. Look in the console. - Zhukov Roman
  • @oOKomarOo, can you have several items on the page with the same ID? - Deonis
  • No, I already checked it .. - oOKomarOo

Try to change $ everywhere on jQuery ... I didn’t work on wordpress either until I changed ...

  • @ jhekonya, jQuery's case, jQuery, so that all the functionality is available without $. If you need to use jQuery, javascript, callback, $ .noConflict (). - Zhukov Roman
  • I have divs in the middle of the column <tr> <td> & nbsp; </ td> <td> & nbsp; </ td> </ tr> When I remove them, it hides. What should I do with this, do not tell me? - oOKomarOo
  • 3
    Learn the basics of HTML. - Zhukov Roman
  • Very useful information. - oOKomarOo
  • 3
    You will be surprised, but this is really very useful information. The people were just getting tired of answering questions in the style of "how to swap two elements in an array." Therefore, the advice to go smoking manuals is the most capacious :). Oh yes! And sometimes google before asking questions on the forums. It trite saves time. - hdimon

look at the find method

    I will not say for the blocks DIV, but with inputs - there were problems. IdI didn’t want to get out, I had to use a name and set a name like ID and

    $ ('div [name = session_true]') ..........