English 中文(简体)
遮掩
原标题:javascript hide show

我试图做一个简单的隐蔽,用javascript来显示功能(NOT Jquery,我要学习);我是我仍然学习的。 我试图做的是Facebook和其他人,当你依靠新闻报道文章时,有一小X显示,可以选择删除。 I m试图在表格上填写(表室)

在此,我的职责是:

function showHide(id) {
    if(document.getDocumentById(id).style.visibility ==  hidden )
        document.getDocumentById(id).style.visibility =  visible ;
    else
        document.getDocumentById(id).style.visibility =  hidden ;
}

和在身体上:

echo  <tr> ;
        echo  <td class="managealbum_delete" id="managealbum_delete .$x. ">X</td> ;
        echo  <td>  . $album->title .  </td> ;
        echo  <td>  . $album->caption .  </td> ;
        echo  <td style="border: 1px solid black;" onMouseOver="showHide( ." ". managealbum_delete .$x." ". );" onMouseOut="showHide( ." ". managealbum_delete .$x." ". );">  . $album->media .  </td> ;
        echo  </tr> ;
问题回答

该功能是getElementById,而不是getDocumentById

function showHide(id) { 
    if(document.getElementById(id).style.visibility ==  hidden )    
        document.getElementById(id).style.visibility =  visible ; 
    else 
        document.getElementById(id).style.visibility =  hidden ; 
}

此外,你可以缩短这个轨道,并检查确保一个要素如:

function showHide(id) {
    var el = document.getElementById(id);
    if( el && el.style.visibility ==  hidden )    
        el.style.visibility =  visible ; 
    else 
        el.style.visibility =  hidden ; 
}

如果你真的想要掩盖它,而不只是抹去其内容,你应当使用:

document.getDocumentById(id).style.display =  none ;

并且为了展示,使用:

document.getDocumentById(id).style.display =  table-cell ;





相关问题
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.

热门标签