js---03属性操作

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>

<script>
window.onload = function (){
    var oBtn = document.getElementById('btn1');
    var oText = document.getElementById('text1');
    var oSelect = document.getElementById('select1');

    oBtn.onclick = function (){    
        alert(oText.value + ' 在 ' + oSelect.value);
    };
    oBtn1.onclick = function (){
        num -= 2;
        oP.style.fontSize = num + 'px';
        // oP.style.font-Size,JS 不允许出现"-"
        // padding-top        paddingTop
        // margin-left        marginLeft
    };
    oBtn3.onclick = function (){
        // oP.class = 'red';
        // class => className
        oP.className = 'red';
    };
    if( oImg.src == 'file:///C:/Users/Administrator/Desktop/11-4-JS1/img/1.jpg' ){
        oImg.src = 'img/2.jpg';
    }
};
</script>

<script>
var oInp = document.getElementById('inp1');

oInp.onclick = function (){
    oInp.type = 'checkbox';
    // 咱们有仨位“祖宗”
    /*
        IE6 IE7 IE8 不支持
    */
};
/*
    oDiv.style.float = 'right';
    oDiv.style.styleFloat = 'right';        // IE
    oDiv.style.cssFloat = 'left';            // 非IE
    IE(styleFloat)
    非IE(cssFloat)
    <div class="right"></div>
*/
</script>

</head>

<body>

</body>
</html>

 

posted @ 2017-05-09 05:08  无天666  阅读(168)  评论(0编辑  收藏  举报