简体   繁体   English

我需要在两个不同的 DIV 中使用相同的 ID 内容。 我该怎么做?

[英]I need to use same ID content in two different DIVs. How do I do it?

Case is this.案例是这样的。 I have a website with two different layouts for browser and mobile.我有一个网站,有两种不同的浏览器和移动布局。 The content should be same with both and i've created DIVs with unique IDs.两者的内容应该相同,并且我创建了具有唯一 ID 的 DIV。 In short the code is this...简而言之,代码是这样的......

 @media only screen and (max-width: 600px) {.mobile { visibility: visible; }.browser { visibility: hidden; } } @media only screen and (min-width: 601px) {.mobile { visibility: hidden; }.browser { visibility: visible; } }
 <div class="browser"> <div id="content">Blaa blaa blaa</div> </div> <div class="mobile"> <div><!--Need to get content from "content" id here--></div> </div>

You can't use same id twice, instead you can use same class name for multiple elements..您不能两次使用相同的id ,而是可以对多个元素使用相同的class名称。

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

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