将HTML和CSS传递给Javascript [英] Passing HTML and CSS to Javascript

查看:222
本文介绍了将HTML和CSS传递给Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到一种方式将可见的div传递给javascript。这可能不是完成我想完成的最好的方式,所以我开放其他建议。

I need to find a way to pass the visible div to javascript. This may not even be the best way to accomplish what I'm trying to accomplish, so I'm open for other suggestions.

我的所有网站内容打开一个单一覆盖。当在导航中点击按钮时,该内容会在叠加层中打开。当点击另一个按钮时,该内容将替换叠加层中的当前内容。等等。

All my site content opens in a single overlay. When a button is clicked in the navigation, that content opens in the overlay. When another button is clicked, that content replaces the current content in the overlay. And so on.

覆盖层打开的最佳标识符(我发现的)是(CSS) display:block ...
,所有隐藏的div都是 display:none ....

The best identifier (that I've spotted) of which overlay is open, is (CSS) display:block...
and all the hidden divs are display:none....

想要通过哪个div具有 display:block 到javascript(注意:所有的div都有唯一的ID)

So I want to pass which div has the display:block to javascript (Note: all the div's have unique ID's)

我相信这很容易,但我似乎找不到...

I'm sure this is something easy, But I can't seem to find it...

预先感谢您的时间!!

Thanks in advance for your time!!

推荐答案

JS中的每个HTML元素都有style属性。您可以通过调用

Each HTML element in JS has style property. You can read and change element style by calling for example

document.getElementById('id').style.display

所以你不需要传递任何东西给JS,它已经存在了。

So you don't need to pass anything to JS, it's already there.

这篇关于将HTML和CSS传递给Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆