⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.js

📁 一个很好的js技术学习的小例子
💻 JS
字号:
$(document).ready(function(){
    $(".title").toggle(
        function()
        {
            $(this).next(".content").slideUp("slow");
        },
        function()
        {
            $(this).next(".content").slideDown("slow");
        }
    );
});

//取文本框的值
function getTextValue()
{
    var html=document.all["htmlText"].value;
    var server=document.all["serverText"].value;
    alert("HTML文本框的值:"+html+"\n服务器文本框的值:"+server);
    return false;
}

//取单选按钮的值
function getRadioValue()
{
    var radios=document.getElementsByName("radio");
    for(var i=0;i<radios.length;i++)
    {
        if(radios[i].checked==true)
        {
            alert(radios[i].value);
        }
    }
    
    return false;
}

//将右边文本框的值赋值到左边的文本框中
function RightToLeft()
{
    var rightVal=document.all["txtRight"].value;
    document.all["txtLeft"].value="";
    if(rightVal.length==0)
    {
        document.all["txtRight"].value="不能为空";
        document.all["txtRight"].style.color="red";
    }
    else
    {
        document.all["txtLeft"].style.color="black";
        document.all["txtLeft"].value=rightVal;
        document.all["txtRight"].value="";
    }
    return false;
}

//将左边文本框的值赋值到右边的文本框中
function LeftToRight()
{
    var leftVal=document.all["txtLeft"].value;
    document.all["txtRight"].value="";
    if(leftVal.length==0)
    {
        document.all["txtLeft"].value="不能为空";
        document.all["txtLeft"].style.color="red";
    }
    else
    {
        document.all["txtRight"].style.color="black";
        document.all["txtRight"].value=leftVal;
        document.all["txtLeft"].value="";
    }
    return false;
}

//双击Table行时间
function AssgnVal(tr)
{
    //获得子节点
    var childs=tr.childNodes;
    
    //firstChild的取值
    //var ID=childs[0].firstChild.nodeValue;
    
    var ID=childs[0].innerText;
    var Content=childs[1].innerText;
    
    //var Operation=childs[2].innerHTML;
    var Operation=childs[2].innerText;
    
    document.getElementById("txtID").value=ID;
    
    //setAttribute(property,value)
    document.all["txtContent"].setAttribute("value",Content);
}

//点击“选择”链接事件
function SelTr(link)
{
    var childs=link.parentNode.parentNode.childNodes;
    //firstChild的取值
    //var ID=childs[0].firstChild.nodeValue;
    
    var ID=childs[0].innerText;
    var Content=childs[1].innerText;
    
    //var Operation=childs[2].innerHTML;
    var Operation=childs[2].innerText;
    //alert(Operation);
    
    document.getElementById("txtID").value=ID;
    
    //setAttribute("property","value")
    document.all["txtContent"].setAttribute("value",Content);
    
    return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -