小编Lèl*_*ull的帖子

如何使用JavaScript更改类的显示?

所以我有这段代码:

    function show_all()
    {
    	document.getElementByClassName('login').style.display = 'inline';
    	document.getElementById('button-hide').style.display = 'inline';
    	document.getElementById('button-show').style.display = 'none';
    };
    function hide_all()
    {
    	document.getElementByClassName('login').style.display = 'none';
    	document.getElementById('button-hide').style.display = 'none';
    	document.getElementById('button-show').style.display = 'inline';
    };
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<nav>
    	<input type="button" value="Show login Buttons" id="button-show" onclick="show_all();"/>
    	<input type="button" value="Hide login Buttons" id="button-hide" onclick="hide_all();"/>
    </nav>
        <p class="login">Username:</p>
        <img src="un.png" class="login"/>
        <p class="login">Password:</p>
    <p>Something not ment to be hidden.</p>
        <img src="pass.png" class="login"/>
Run Code Online (Sandbox Code Playgroud)

而且我需要显示/隐藏整个班级;我有大约50个带有“登录”类元素的块,我只想使用JavaScript来显示它。

html javascript css

5
推荐指数
2
解决办法
2万
查看次数

一个条件,多个事件

我试图弄清楚如何使用.vbs只使用一个条件来发生多个事件.(这里我尝试使用case语句.)是否有这样的命令,或者我是否必须为每一行重写命令?(这可以通过在之前的代码行中激活它来在记事本上输入.)

  msgbox("I was woundering how old you are.")
    age=inputbox("Type age here.",,"")
    Select Case age
    Case age>24
        x=age-24
        WshShell.SendKeys "I see you are "&x&" years older than me."
        WshShell.SendKeys "{ENTER}"
    Case age<24
        x=24-age
        WshShell.SendKeys "I see you are "&x&" years younger than me."
        WshShell.SendKeys "{ENTER}"
    Case age=24
        WshShell.SendKeys "Wow were the same age!"
        WshShell.SendKeys "{ENTER} "
    End Select
Run Code Online (Sandbox Code Playgroud)

vbscript events conditional-statements

3
推荐指数
1
解决办法
3651
查看次数

如何在jQuery中迭代类?

问题是所有卡都是相同的颜色,我想要的是每个卡在页面加载时随机给出五种颜色中的一种.

这是我尝试使用的代码:

$( document ).ready(function() {
    oneToFive = Math.floor((Math.random() * 5) + 1);
    switch (oneToFive) {
        case 1:
            randColor = "rgba(255, 255, 255, 0.25)";
            break;
        case 2:
            randColor = "rgba(0, 0, 255, 0.25)";
            break;
        case 3:
            randColor = "rgba(0, 0, 0, 0.25)";
            break;
        case 4:
            randColor = "rgba(255, 0, 0, 0.25)";
            break;
        case 5:
            randColor = "rgba(0, 255, 0, 0.25)";
            break;
        default:
            randColor = "rgba(122, 122, 122, 0.25)";
            break;
    }

    $(".card-color").each(function(){
        $(".card-color").css("background-color", randColor);
    });
});
Run Code Online (Sandbox Code Playgroud)

jquery

1
推荐指数
1
解决办法
106
查看次数