Building a layer stacking fine table with JavaScript + DIV

xiaoxiao2021-04-08  396

If you are more familiar with HTML, I believe that you will not be unfamiliar with the DIV positioning tag? In fact, the fancy table is a hidden div, which is actually existed at the beginning, but it is hidden. When we click on a particular flag in the primary table, you pass an event (such as Click)

) Set it to the display.

Ok, the principle, you are already clear, how do you implement it? Next we first design a form, from above, we know that the table's form should be designed, and the form of the schedule should be included in a cell of the primary table, so that it can achieve a good effect. The code for establishing a table should be in the process of being included in multiple records in the loop read data sheet, otherwise it is not expected. We should create one when the primary table is displayed

Div

Mark (each tag should have a unique

id

Identification) to respond to events, such as:

<

% J

=

1

DO

While

NOT

Rs.eof%

>

<

TR

>

'

Define a DIV tag for a main1, main2 sequence

<

DIV ID

=

"

main

<

%

=

J%

> "

Class

=

"Menu" width

=

"

100

%

>

'

Let the number response click event

<

TD Height

=

"

twenty two

"

> <

a href

=

# Title

=

"Click here to expand

/

Folding "onclick

=

Expandit (

"

& j &

"

Return

False

"

> <

%

=

RS (

"

id

"

)%

>

a

>

TD

>

Div

>

'

......

TR

>

<

% J

=

j

1

rs.movenext

loop

%

>

Each time a primary table record is displayed, we should read the relevant charted table record and use another

Div

The tag contains all relevant detailed records and contains. In combination with the above process, we have the following statements:

DO

While

NOT

Rs.eof

<

TR

>

"Defines a DIV tag that ID is Main1, Main2 sequence, class is MENU

<

DIV ID

=

"

"

& j &

"

"Class"

=

"Menu" width

=

"

100

%

>

'

Let the number response click event

<

TD Height

=

"

twenty two

"

> <

a href

=

# Title

=

"Click here to expand

/

Folding "onclick

=

Expandit (

"

& j &

"

Return

False

"

> <

%

=

RS (

"

id

"

)%

>

a

>

TD

>

Div

>

"...

TR

>

<

TR

> <

TD

>

'

Define an ID to Page1, Page2 Sequence, Class for Child's DIV tag <

DIV ID

=

"Page

"

& j &

"

"Class"

=

"Child"

>

<

Table Border

=

"

1

"Width

=

"

100

%

>

'

Recipient reading record here

TABLE

>

Div

>

TD

>

TR

>

j

=

j

1

rs.movenext

loop

Designed

Div

After the tag and the form display the page, then

JavaScript

To design a responsive event statement, you have hidden at the beginning of the page, click one

Id

Only the relevant detailed records are displayed and the purpose of hiding other undesirable details.

FUNCTION

INITIT () {Divcount

=

Document.all.tags

"

Div

"

);

for

(i

=

0

I

<

Divcount.length; i

) {OBJ

=

Divcount (i);

IF

(Obj.className

==

"

Child

"

||

Obj.classname

==

"

Child1

"

) Obj.Style.display

=

"

None

"

}}

VAR

PriorID

=

1000

;

FUNCTION

Expandit (EL) {DIVCOUNT

=

Document.all.tags

"

Div

"

);

for

(i

=

0

I

<

Divcount.length; i

) {OBJ

=

Divcount (i);

IF

(Obj.className

==

"

Child

"

||

Obj.classname

==

"

Child1

"

)

IF

(PriorID)

! =

EL) {Obj.Style.display

=

"

None

"

}} Priorid

=

El; Obj2

=

evAl

"

page

"

EL); OBJ4

=

evAl

"

main

"

EL);

IF

(Obj2.style.disPlay

==

"

None

"

) {Obj2.style.display

=

"

Block

"

}

Else

{Obj2.Style.disPlay

=

"

None

"

}} Online

=

Initit;

the above

JavaScript

The specific syntax means I will not be detailed,

initit

The function of the function is that all hidden schedules are closed when loading or refreshing.

Expandit

The function of the function is to show the relevant list of storms to hide other undesirable sheets. It can be seen that

JavaScript Div

The way the details are simple and efficient, and the interface effect is also easy for users to accept.

Click on the figure below to watch the detailed effect, welcome you to correct.

转载请注明原文地址:https://www.9cbs.com/read-132761.html

New Post(0)