最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - How to remove the opacity in javascript? - Stack Overflow

programmeradmin0浏览0评论

I have a view privacy policy. I added the opacity for my div but now I don't know how to remove the opacity. I am trying with remove the attribute but its not working. Can someone kindly assist me? Its a very urgent requirement.

<script type="text/javascript">


    function show(id)
    {
       if(document.getElementById("wrapper")) //check the element exists and can be accessed
       {   
           var ele = document.getElementById("wrapper");//get hold of the element
           if(ele.style.visibility=="visible")//see if display property is set to none
           {   
           }
           else
           {
                ele.style.visibility="visible";
               document.getElementById('LOGIN').style.opacity = 0.4;

           }
       }
    } 

    function hide(id)
    {
       if(document.getElementById("wrapper"))//check the element exists and can be accessed
       {    
           var ele = document.getElementById("wrapper");//get hold of the element
           if(ele.style.visibility=="visible")//see if display property is set to none
           {   
               ele.style.visibility="hidden"; 
           }
           else
           {

           }
       }
    } 

</script>
<style>
#wrapper {
position:absolute; 
z-index:1;
top:11%; bottom:5%; left:4%;right:15%;
width:87%;
height:75%;
font-size:15pt;
border:5px solid orange;
border-radius:25px;
overflow:auto;
visibility:hidden;
background-color:#ffffff;

}

#LOGIN.faded {
  opacity: 0.5;

}

</style>
  </head>
  <body >
   <div id="LOGIN" align="center">

            <table width="100%">
                <tr>
                    <td>
                        <input type="image" src="../images/header-sign-up.png" style="width:100%" alt=""/>
                    </td>
                </tr>
            </table>
            <div align="center">
                <a href="#" onclick ="show('showhide');">View privacy policy</a>

            </div>

   </div>
   <div id="wrapper">
                    <div id="scroller" >
                        <div id="popupContact" >
                            <a href="#" onclick ="hide('showhide');">Close Window</a><br/>
                            <p>
                                &nbsp;&nbsp;biler Privacy Policy

                                &nbsp;Please feel free to contact us with any ments, questions, plaints or suggestions you might have regarding the information practices described in this statement. You may send us an e-mail at 
                          </p>  
                        </div>
                    </div>
                </div>
   </body>
</html>

I have a view privacy policy. I added the opacity for my div but now I don't know how to remove the opacity. I am trying with remove the attribute but its not working. Can someone kindly assist me? Its a very urgent requirement.

<script type="text/javascript">


    function show(id)
    {
       if(document.getElementById("wrapper")) //check the element exists and can be accessed
       {   
           var ele = document.getElementById("wrapper");//get hold of the element
           if(ele.style.visibility=="visible")//see if display property is set to none
           {   
           }
           else
           {
                ele.style.visibility="visible";
               document.getElementById('LOGIN').style.opacity = 0.4;

           }
       }
    } 

    function hide(id)
    {
       if(document.getElementById("wrapper"))//check the element exists and can be accessed
       {    
           var ele = document.getElementById("wrapper");//get hold of the element
           if(ele.style.visibility=="visible")//see if display property is set to none
           {   
               ele.style.visibility="hidden"; 
           }
           else
           {

           }
       }
    } 

</script>
<style>
#wrapper {
position:absolute; 
z-index:1;
top:11%; bottom:5%; left:4%;right:15%;
width:87%;
height:75%;
font-size:15pt;
border:5px solid orange;
border-radius:25px;
overflow:auto;
visibility:hidden;
background-color:#ffffff;

}

#LOGIN.faded {
  opacity: 0.5;

}

</style>
  </head>
  <body >
   <div id="LOGIN" align="center">

            <table width="100%">
                <tr>
                    <td>
                        <input type="image" src="../images/header-sign-up.png" style="width:100%" alt=""/>
                    </td>
                </tr>
            </table>
            <div align="center">
                <a href="#" onclick ="show('showhide');">View privacy policy</a>

            </div>

   </div>
   <div id="wrapper">
                    <div id="scroller" >
                        <div id="popupContact" >
                            <a href="#" onclick ="hide('showhide');">Close Window</a><br/>
                            <p>
                                &nbsp;&nbsp;biler Privacy Policy

                                &nbsp;Please feel free to contact us with any ments, questions, plaints or suggestions you might have regarding the information practices described in this statement. You may send us an e-mail at 
                          </p>  
                        </div>
                    </div>
                </div>
   </body>
</html>
Share Improve this question edited Aug 27, 2012 at 6:23 JavaH asked Aug 27, 2012 at 6:11 JavaHJavaH 4272 gold badges11 silver badges29 bronze badges 1
  • 2 turn opacity value to 1.0 ? Also see quirksmode/js/opacity.html to make it work in IE – DhruvPathak Commented Aug 27, 2012 at 6:15
Add a ment  | 

3 Answers 3

Reset to default 3

Try opacity as you already have, or display...

document.getElementById('varContent').style.opacity = 0;
document.getElementById('varContent').style.opacity = 1;

or

document.getElementById('varContent').style.display = 'none';
document.getElementById('varContent').style.display = 'block';

You have to make the opacity value 1.

with web kit based browsers setting opacity of 1 will (unnecessarily ) slow down down the display (especially when scrolling content with opacity 1 over a background image)

better remove the property altogether (either using "removeProperty" method if you are certain it is available (IE 9 or better):

element.style.removeProperty("opacity")

or, more patible:

element.style.opacity = ""
发布评论

评论列表(0)

  1. 暂无评论