我在使用Javascript更改對象顯示屬性時遇到問題。更改顯示屬性將頁面滾動到頂端
我填補數據表中使用php
一個mysql
數據庫,併爲每一行這讓我想一個DIV
與display:none
財產,我有一個簡單的JavaScript函數來顯示/隱藏div
。 這裏是css
爲div
:
display:none; /*initially menu item is hidden*/
position: absolute; /*absolute positioning to float*/
background-color:#fff;
width:230px;
min-height:120px;
right:60px;
border:5px solid #ccc;
text-align:right;
direction:rtl;
padding:10px;
border-radius: 10px 10px 10px 10px;
-moz-border-radius: 10px 10px 10px 10px;
-webkit-border-radius: 10px 10px 10px 10px;
,這是JavaScript:
function showfield (a) {
document.getElementById(a).style.display = "block";
}
function hidefield (a) {
document.getElementById(a).style.display = "none";
}
功能的工作原理和申報單顯示,在他們必須在地方,但問題是:
當我調用JavaScript函數顯示,它顯示的div,但頁面滾動到頂部,並看到打開的div我應該向下滾動,因爲我的頁面是一個報告頁面,它可能是一個很長的頁面,這不是一個好happeni一切!
我不明白爲什麼會發生這種情況,是否有辦法阻止這種自動滾動?
讓我猜....ü在'叫你'showfield'功能'標籤...喜歡...'.. is it???? – bipen
hi can you please write html code here. –
@bipen Yes i called it in a tag as you say –