Home > front end >  I am in PHP cycle div, how to use js show hidden div?
I am in PHP cycle div, how to use js show hidden div?

Time:10-04

Because's cycle so id are equal, js every time can only be the first div show hidden, and how to do

CodePudding user response:

No one will be?

CodePudding user response:

Didn't quite understand your code id generally only allow the existence of a
As you said you can add a div outside this loop hidden as a whole

CodePudding user response:

reference 2 floor console. The log () response:
didn't quite understand your code id generally only allow the existence of a
As you say you can add a div outside this loop integral hidden

I query the database, then the while loop div output to the HTML page, so the id is the same,
Id there is only one word, then I know how to do it under each div, information,

CodePudding user response:

Given cycle, don't use id, class, want to hide which used the corresponding index

CodePudding user response:

Page element id should be unique, id not to repeat, repeat. Id with document getElementById () or jquery $(" # id ") access, can only get to the first,
To obtain multiple elements, should use the elements of the class, and getElementsByClassName () or jquery $(" class "),
If you must use id, you can also use the document. The querySelectorAll (" # id ") to get more elements,

CodePudding user response:

Id is the only you want hidden div must have hidden conditions, and then corresponding qualified div set in the CSS display: none
  • Related