简体   繁体   English

如何在javascript中的div中显示元素?

[英]How to get displayed element in div at javascript?

How to get displayed element in div at javascript?. 如何在javascript的div中显示元素? I have a div element on my page. 我的页面上有一个div元素。 There are 4 img objects in Div element. Div元素中有4个img对象。 I made a slider by sliding these pictures up from below. 我通过从下面向上滑动这些图片制作了一个滑块。 How do I get the img object shown in that div inside? 如何获取该div中显示的img对象?

i think that you can set an id on yours images and create a var active_img in javascript 我认为您可以在自己的图片上设置ID并在javascript中创建var active_img

When the user use the slide you need to call a function who change the active_img var like 当用户使用幻灯片时,您需要调用一个更改active_img var的函数,例如

active_img=active_img+1;

And to get the active image you can do this : 要获得活动图像,您可以执行以下操作:

Var obj=document.getElementById("img_id");

This will work but i think there is also an another way to do that you want. 这将起作用,但是我认为还有另一种方法可以做到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM