English 中文(简体)
Java 挣扎,特别是改变 c类特性
原标题:Javascript- struggling, especially with changing css classes attributes

由于诸如这样的网站,我已经学到了超文本、中文本服务公司、PHP和KQ,达到一个相当好的标准。 然而,我确实在与贾瓦特作斗争。

在我的具体案例中,我的结论是,对我的菜单而言,我最好使用表格,而不是 drop倒——我知道,在持续的辩论中,我发现这是最好的解决办法。

我了解了W3Schools的表格,并利用他们的榜样,在失去重点时尝试和结束每一条表格,但我找不到这样做的任何方法。 供参考,我附上下文W3Schools(按T&收成)的光带。 我确信,我不是 la笑,我已经理解如何将这种说法转换为计算机/智能电话(包括汉堡门菜单),并将用数据库驱动的PHP/SQL-把菜单填满,但这里只是“什么”来避免混乱。

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: Arial;}

/* Style the tab */
.tab {
  overflow: hidden;
  border: 1px solid #ccc;
  background-color: #f1f1f1;
}

/* Style the buttons inside the tab */
.tab button {
  background-color: inherit;
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 16px;
  transition: 0.3s;
  font-size: 17px;
}

/* Change background color of buttons on hover */
.tab button:hover {
  background-color: #ddd;
}

/* Create an active/current tablink class */
.tab button.active {
  background-color: #ccc;
}

/* Style the tab content */
.tabcontent {
  display: none;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-top: none;
}

/* Style the close button */
.topright {
  float: right;
  cursor: pointer;
  font-size: 28px;
}

.topright:hover {color: red;}
</style>
</head>
<body>

<h2>Tabs</h2>
<p>Click on the x button in the top right corner to close the current tab:</p>

<div class="tab">
  <button class="tablinks" onclick="openCity(event,  London )" id="defaultOpen">London</button>
  <button class="tablinks" onclick="openCity(event,  Paris )">Paris</button>
  <button class="tablinks" onclick="openCity(event,  Tokyo )">Tokyo</button>
</div>

<div id="London" class="tabcontent">
  <span onclick="this.parentElement.style.display= none " class="topright">&times</span>
  <h3>London</h3>
  <p>London is the capital city of England.</p>
</div>

<div id="Paris" class="tabcontent">
  <span onclick="this.parentElement.style.display= none " class="topright">&times</span>
  <h3>Paris</h3>
  <p>Paris is the capital of France.</p> 
</div>

<div id="Tokyo" class="tabcontent">
  <span onclick="this.parentElement.style.display= none " class="topright">&times</span>
  <h3>Tokyo</h3>
  <p>Tokyo is the capital of Japan.</p>
</div>

<script>
function openCity(evt, cityName) {
  var i, tabcontent, tablinks;
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";
  }
  tablinks = document.getElementsByClassName("tablinks");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" active", "");
  }
  document.getElementById(cityName).style.display = "block";
  evt.currentTarget.className += " active";
}

// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
   
</body>
</html> 

我试图这样做。

<div id="London" class="tabcontent" onblur="style.display.visibility= none ">Lorem Ipsum....</div>

每一个例子和许多类似的例子似乎都没有工作。

我也曾尝试过几次听觉,如上所述,但我无法工作。

我可以找到100人提出这一问题或类似问题,但我不理解我需要做什么来复制或改变我的例子。 确实会有帮助的不仅是我知道我失踪的几条法典,还有人补充说,“这里是这样做的,那里是这样......和”的,因为这有助于我理解。

很多人预先表示感谢。 抱歉,如果我 asked问这个问题,尽管去年已经学习了其他一切,这是我第一次要求一个论坛。

问题回答

内容没有因违约而得到重视,因此,你可以使用<代码>onblur<>/code>。 https://stackoverflow.com/questions/18504139/div-onblur-Function”>。





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签