English 中文(简体)
我怎么能够用javascript打开一片 d? 2. 改变和改变
原标题:How can I open a div with javascript ? Mouseover & Mouseout style

我的大麻在我的网站上设置了链接,我希望它能够打开转播位置的四分之四,如果切断链接,我想关闭。 如果有人能帮助我? 如果你能够书写职能的话,那将是一件很麻烦的事,因为那是因为: 它打开了12个不同的干.。

我尝试了这个例子,但努力工作。

<div id="mydiv" style="display: none">
  <h3>This is a test!<br> Can you see me?</h3> 
</div>
<p> 
  <a href="javascript:;" 
     onMouseOver="document.getElementById( mydiv ).style.display =  block ; }"    
     onMouseOut="document.getElementById( mydiv ).style.display =  none ; }">
     Toggle Div Visibility
  </a>
</p>
最佳回答

你只是需要清理一些特性——最终还有额外的“}”。

<a href="javascript:;" 
     onMouseOver="document.getElementById( mydiv ).style.display =  block "    
     onMouseOut="document.getElementById( mydiv ).style.display =  none ">
   Toggle Div Visibility
</a>

或者,你可以按照你的建议写一个职务:

<a href="javascript:;" 
      onMouseOver="showElement( mydiv )" onMouseOut="hideElement( mydiv )">
   Toggle Div Visibility
</a>
<script type="text/javascript">
   function showElement(id) {
      document.getElementById(id).style.display =  block ;
   }
   function hideElement(id) {
      document.getElementById(id).style.display =  none ;
   }
</script>
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签