JavaScript点击一次,我写了一个将按钮的颜色改为绿色,当我再次点击按钮时,它的颜色应该变回橙色.按钮的默认颜色为橙色.我已经给出了rgb颜色的值.但是,当我点击按钮时,它的颜色从橙色变为绿色,当我再次点击它时,它的颜色保持绿色不会变回橙色.请帮我解决这个问题.
<script>
function colorchange(id)
{
var background = document.getElementById(id).style.background;
if(background = "rgb(255,145,0)")
{
document.getElementById(id).style.background = "rgb(26,255,0)";
}
if(background == "rgb(26,255,0)")
{
document.getElementById(id).style.background = "rgb(255,145,0)";
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
这是输入按钮的HTML代码
<input type="button" name="Ignore Select" value="Ignore Select" id="select" onclick="colorchange('select')" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Delete" value="Ignore Delete" id="select1" onclick="colorchange('select1');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Insert" value="Ignore Insert" id="select2" onclick="colorchange('select2');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Update" value="Ignore Update" id="select3" onclick="colorchange('select3');" style="background:rgb(255,145,0);"/>
<input type="button" name="Ignore Sleep" value="Ignore Sleep" id="select4" onclick="colorchange('select4');" style="background:rgb(255,145,0);"/>
Run Code Online (Sandbox Code Playgroud) 我有一个包含以下内容的文件.其中我想在一个特定的子标题下显示线条.我尝试使用一些sed和awk命令,但我无法得到它.任何人都可以通过一些linux命令帮助解决这个问题.
[first attempt]
a=10
b=20
[second attempt]
a=20
b=20
[third attempt ]
a=30
b=50
Run Code Online (Sandbox Code Playgroud)
是否可以通过使用awk或sed或cut命令指定侧标题,单独显示"[second attempt]"侧标题下的内容或单独任何其他标题下的内容.输出应如下.提前致谢.
[second attempt]
a=20
b=20
Run Code Online (Sandbox Code Playgroud)