- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对 css 和 javascript 完全不熟悉,如果这可能是一些基本的东西,我很抱歉。我正在尝试整理一个显示建筑物概览的表格。当用户单击任何楼层链接时,一个表格会更改为另一个表格(它们都在不同的 div 中。当用户将鼠标移到它上面时,它会显示有关每个单独单元的更多信息,无论是出租、出售,还是无法使用。我现在要创建的是一些链接,这些链接在单击时会更改每个单元格的背景。因此,例如,当点击 show rental units 时,id='rent' 和 'both' 的所有单元格的背景都会发生变化在此处查看演示:http://encanto.ximg.co/overviewdemo.html
这是第一个表格的完整源代码(包括 css)。我确定它在我试图显示/隐藏 td 单元格的某个地方也是一团糟。但我似乎只能找到告诉 td 在您单击 td 时更改颜色的函数,而不是 href。正如我所说,我是一个彻头彻尾的 n00b,所以请保持温柔。
<style type="text/css">
table.overview a {
border:none;
display: block;
}
table.overview td {
max-height:150px;
max-width:150px;
background:#96843c;
}
div.overview td:hover {
background:#ffffff;
}
div.overview td.white {
background:#ffffff;
}
div.overview a {
color: #ffffff;
text-decoration:none;
text-align:center;
letter-spacing: 1px;
font-size:16px;
line-height:32px;
font-family:"Century Gothic", helvetica, sans-serif;
padding: 2px 5px;
}
div.overview p {
color:#96843c;
text-decoration:none;
text-align:center;
letter-spacing: 1px;
font-size:10px;
line-height:10px;
font-family:Georgia, "Times New Roman", Times, serif;
}
div.overview a:hover {
color: #96843c;
background: #ffffff;
font-family: "Century Gothic";
}
</style>
<script type="text/javascript"><!--
function show_visibility(){
for(var i = 0,e = arguments.length;i < e;i++){
var myDiv = document.getElementById(arguments[i]).style;
myDiv.display = "block";
}
}
function hide_visibility(){
for(var i = 0,e = arguments.length;i < e;i++){
var myDiv = document.getElementById(arguments[i]).style;
myDiv.display = "none";
}
}
</script>
<table summary="" cellpadding="1" cellspacing="1" class="floor">
<tr>
<td>
<a href="#"onClick="show_visibility('floor1');hide_visibility('floor2');hide_visibility('penthouse') ">Ground Floor</a>
</td>
<td>
<a href="#" onClick="show_visibility('rental');show_visibility('both');hide_visibility('sales');hide_visibility('na') ">Show Rental Units</a>
</td>
</tr>
<tr>
<td>
<a href="#" onClick="show_visibility('floor2');hide_visibility('floor1');hide_visibility('penthouse')">1st Floor</a>
</td>
</tr>
<tr>
<td>
<a href="#" onClick="show_visibility('penthouse');hide_visibility('floor1');hide_visibility('floor2')">Penthouse</a></td>
</tr>
</table>
<div id='floor1' class="overview" style="display:none">
<table summary="" cellpadding="1" cellspacing="1" class="overview" width="630">
<tr>
<td colspan="12" height="25" class="white"></td>
</tr>
<tr>
<td colspan="1" rowspan="7" width="25" class="white"><img src="http://encanto.ximg.co/calle10.jpg" /></td>
<td colspan="8" height="25" class="white"><img src="http://encanto.ximg.co/adjacent.jpg" /></td>
<td colspan="1" rowspan="7" width="25" class="white"><img src="http://encanto.ximg.co/calle12.jpg" /></td>
<td colspan="1" rowspan="7" width="25" class="white"></td>
</tr>
<tr>
<td colspan="4" id="sale"><a href="http://www.encantoriviera.com/unit14/"onfocus="this.blur()">
14</a>
<p>
<strong>FOR SALE</strong>
<br />
2 Bed/2 Bath
<br />
1131 sq ft./105 sq m.
</p>
</a>
</td>
<td colspan="4" id="na"><a href="http://www.encantoriviera.com/real-estate/vacation-rentals/"onfocus="this.blur()">1</a>
<p>
<strong>NOT AVAILABLE</strong>
<br />
2 Bed/2 Bath
<br />
1677 sq ft./156 sq m.
</p>
</a>
</td>
</tr>
<tr>
<td colspan="2" width="150" id="na"><a href="http://www.encantoriviera.com/"onfocus="this.blur()">
13
<p>
<strong>NOT AVAILABLE</strong>
<br />
1 Bed/ 1.5 Bath
<br />
840 sq ft./78 sq m.
</p>
</a>
</td>
<td colspan="4" rowspan="4" width="300" class="white">
</td>
<td colspan="2" width="150" id="na"><a href="http://www.encantoriviera.com/"onfocus="this.blur()">
2
<p>
<strong>NOT AVAILABLE</strong>
<br />
2 Bed/ 2 Bath
<br />
872 sq ft./82 sq m.
<br />
</p>
</a>
</td>
</tr>
<tr>
<td colspan="2" width="150" id="sale"><a href="http://www.encantoriviera.com/unit12/"onfocus="this.blur()">
12
<p>
<strong>FOR SALE</strong>
<br />
1 Bed/ 1.5 Bath
<br />
850 sq ft./79 sq m.
<br />
</p>
</a>
<td colspan="2" width="150" id="na"><a href="http://www.encantoriviera.com/"onfocus="this.blur()">
3
<p>
<strong>SOLD</strong>
<br />
2 Bed/ 2 Bath
<br />
1130 sq ft./105 sq m.
</p>
</a>
</td>
</tr>
<tr>
<td colspan="2" width="150" id="na"><a href="http://www.encantoriviera.com/"onfocus="this.blur()" >
11
<p>
<strong>NOT AVAILABLE</strong>
<br />
2 Bed/ 2 Bath
<br />
1071 sq ft./101 sq m.
<br />
</p>
</a>
<td colspan="2" width="150" id="both"><a href="http://www.encantoriviera.com/unit4/"onfocus="this.blur()">
4
<p>
<strong>FOR SALE AND RENT</strong>
<br />
2 Bed/ 2 Bath
<br />
1092 sq ft./101 sq m.
</p>
</a>
</td>
</tr>
<tr>
<td colspan="2" width="150" id="na"><a href="http://www.encantoriviera.com/"onfocus="this.blur()" >
10
<p>
<strong>NOT AVAILABLE</strong>
<br />
2 Bed/ 2 Bath
<br />
1087 sq ft./101 sq m.
</p>
</a>
<td colspan="2" width="150" id="na"><a href="http://www.encantoriviera.com/"onfocus="this.blur()">
5
<p>
<strong>SOLD</strong>
<br />
2 Bed/ 2 Bath
<br />
1092 sq ft./101 sq m.
</p>
</a>
</td>
</tr>
<tr>
<td colspan="2" width="150" id="na"><a href="http://www.encantoriviera.com/"onfocus="this.blur()">
9
<p>
<strong>SOLD</strong>
<br />
2 Bed/ 2.5 Bath
<br />
1506 sq ft./140 sq m.
</p>
</a>
</td>
<td colspan="2" width="150" id="na"><a href="http://www.encantoriviera.com/unit8/"onfocus="this.blur()">
8
<p>
<strong>FOR SALE AND RENT</strong>
<br />
1 Bed/ 1.5 Bath
<br />
915 sq ft./85 sq m.
</p>
</a>
</td>
<td colspan="2" width="150" id="sale"><a href="http://www.encantoriviera.com/unit7/"onfocus="this.blur()">
7
<p>
<strong>FOR SALE</strong>
<br />
1 Bed/ 1 Bath
<br />
824 sq ft./75 sq m.
</p>
</a>
</td>
<td colspan="2" width="150" id="sale"><a href="http://www.encantoriviera.com/unit6/"onfocus="this.blur()">
6
<p>
<strong>FOR SALE AND RENT</strong>
<br />
1 Bed/ 1.5 Bath
<br />
869 sq ft./81 sq m.
</p>
</a>
</td>
</tr>
<tr>
<td colspan="12" max-height="25" class="white"><img src="http://encanto.ximg.co/avenida20.jpg" /></td>
</tr>
</table>
</div>
最佳答案
您已拥有获得预期结果所需的一切。基本逻辑存在于您提供的两个 JavaScript 函数中。您只需告诉 JavaScript 更改 backgroundColor
而不是更改 display
属性。
我建议使用更具描述性的名称创建两个新函数(例如:highlightCell
)并更改在 for
循环中更改的属性。
关于javascript - onclick href 更改 td 背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7315571/
我正在尝试通过 node.js 中的 puppeteer 抓取数据 目前,我正在寻找一个脚本,用于抓取 well.ca 某个部分中的所有数据 现在,这是我试图通过 node.js 实现的方法/逻辑 1
href=""、href="#" 和 href="javascript:void(0)" 之间有什么区别? 它们有哪些不同的用途,什么时候一个比另一个更好? 最佳答案 href=""将重新加载当前页面
这是html代码: Delivery Schedule Route Abstract Report 我有 href 值。使用 href 值,我应该找到 anchor 标记并使用 jQuery
我不确定是不是因为我使用的是 Wordpress 但 this.href 没有返回包含它们的项目的 href(例如在“联系人”上它返回 http://www.domain.net/undefined反
这个问题在这里已经有了答案: Is there a "previous sibling" selector? (33 个答案) 关闭 8 年前。
这个问题在这里已经有了答案: Are you allowed to nest a link inside of a link? (9 个回答) 关闭 6 年前。 我有一个可点击的面板,其中有一个工具
我的 css 如下所示 ul.sometclass li a { display:inline-block; } 我的 html 看起来像 outer test
我没看明白这段代码是什么意思? a[href*=#]:not([href=#]) 谢谢! 最佳答案 简单地: a[href*=#] 获取 href 中包含 # 的所有 anchor (a)。 但是有:
document.getElementById("IDOFELEMENT"); 将其转换为链接的正确方法是什么? 我可以写吗 document.getElementById("IDOFELEME
所以我在我的 Next JS 应用程序中遇到了这个奇怪的问题,我导入了谷歌字体,如下所示 在我的浏览器中显示的不是 href,而是 data-href="...",所以问题是谷歌无法将此识别为链接
我想获取所选选项的 href 值,以便我现在可以转到使用按钮选择的链接。 这是我的代码
我正在尝试获取我的一个链接的 href 并将其克隆/复制到另一个链接的 href 这是我正在尝试的 var link = $('.topbook'); var link2 =
我基本上是试图从一个链接获取href,然后将其填充到另一个链接中: HTML: Link to thing Link to duplicate 脚本: $('.main-link').attr('hr
我使用的 CSS 工具提示必须包含在“a href”中才能工作。 iPad [add_to_cart_anchor item="ipad"]purchase the iPad[/add_to_c
我有一个以前是纯文本的电子邮件正文,但现在我把它变成了 HTML。电子邮件是使用多种方法生成的,但没有一种方法易于转换。 我有的是: Some content emailaddress@somethi
我正在尝试从网页中抓取数据,然后通过提取下一页的 href 来转到下一页。 但是,在这种情况下,包含下一页的 href 的标签是 href='#next'。使用 Chrome 检查此元素后,当我将鼠标
在我的 html 页面中,我看到一个链接,其“查看源代码”代码如下: 当我将鼠标悬停在链接上并单击它时,我看到了一个有效链接。但我无法找到生成此 URL 的位置和方式。我发现类 a.view 是在其
看完这篇文章net.tutsplus.com/tutorials/javascript-ajax/14-helpful-jquery-tricks-notes-and-best-practices/我
我想用 SvelteKit 构建一个 Web 应用程序,其中一页列出所有项目(带有潜在的搜索查询参数),然后每个单独的项目一页。如果我必须使用后端生成的所有内容以老式方式构建它,我的路径将是 /ite
此 js 搜索包含 page=fleet 的 href其中: var links = document.querySelectorAll('a[href*="page=fleet"]'); var h
我是一名优秀的程序员,十分优秀!