הוסטס - פורום אחסון האתרים הגדול בישראל

הוסטס - פורום אחסון האתרים הגדול בישראל (https://hosts.co.il/forums/index.php)
-   פורום תיכנות (https://hosts.co.il/forums/forumdisplay.php?f=14)
-   -   [בעיה js] להסתיר ולהראות שכבות (https://hosts.co.il/forums/showthread.php?t=60072)

FuZuL 16-02-08 04:27

[בעיה js] להסתיר ולהראות שכבות
 
הבעיה בקוד הבא:
שאני לוחץ על הקישור הוא לא מעלים את הdiv.

קוד:

<script>
function showC(a)
{
        //alert(a);
        document.getElementById(a).style.visibility = "visible";
}
</script>
<body>
<a name="aaa" onclick="showC(this.name);">asdsd</a>
<div id="aaa" align="center" style="visibility:hidden;">
asdasdads64654
</div>

עזרה..?

Ron | CSite.co.il 16-02-08 11:10

הנה הקוד הנכון:

PHP קוד:

<script language="javascript" type="text/javascript">
    function 
show_Response(id)
    {
        
document.getElementById(id).style.display =
        (
document.getElementById(id).style.display=='none')?'block':'none';
    }
</script>

<a href="javascript:void(0);" onclick="show_Response('1')"> ssss </a>
<div id="1" style="display:none;">
asdasdads64654
</div> 


reXtea 16-02-08 11:25

ציטוט:

נכתב במקור על ידי Ron-Pro (פרסם 609380)
הנה הקוד הנכון:

PHP קוד:

<script language="javascript" type="text/javascript">
    function 
show_Response(id)
    {
        
document.getElementById(id).style.display =
        (
document.getElementById(id).style.display=='none')?'block':'none';
    }
</script>

<a href="javascript:void(0);" onclick="show_Response('1')"> ssss </a>
<div id="1" style="display:none;">
asdasdads64654
</div> 


אני רוצה לחזק את התגובה של RON-PRO ולהגיד שהרבה יותר עדיף להשתמש בdisplay=none מכוון שvisibility הוא רק מסתיר ולא מעלים את האובייקט... ככה שהוא עדיין תופס את אותו שטח רק פשוט בלתי נראה... אבל אני מאמין שאתה רוצה שהשטח שהוא יתפוס יקטן...

בהצלחה :]


כל הזמנים הם GMT +2. הזמן כעת הוא 05:23.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ