doStuff(document.getElementById("myCircle1" "myCircle2" "myCircle3" "myCircle4"));
Run Code Online (Sandbox Code Playgroud)
这不起作用,所以我需要逗号或分号才能使其工作吗?
我想在我的圈子上放两个过滤器.(也许更多)
我试过做:
filter="url(#f1);url(#f2)"
Run Code Online (Sandbox Code Playgroud)
和:
filter="url(#f1,#f2)"
Run Code Online (Sandbox Code Playgroud)
和:
filter="url(#f1 #f2)"
Run Code Online (Sandbox Code Playgroud)
但它们都不起作用.我该如何处理这个问题?
<script type="text/ecmascript">
<![CDATA[
function setCoordinates(circle) {
var centerX = Math.round(Math.random() * 1000);
var centerY = Math.round(Math.random() * 1000);
circle.setAttribute("cx",centerX);
circle.setAttribute("cy",centerY);
}
]]>
</script>
<circle class="circles" cx="500" cy="500" r="25" fill="white" filter="url(#f1)" />
<circle class="circles" cx="500" cy="500" r="25" fill="white" filter="url(#f1)" />
<circle class="circles" cx="500" cy="500" r="25" fill="white" filter="url(#f1)" />
<circle class="circles" cx="500" cy="500" r="25" fill="white" filter="url(#f1)" />
<circle class="circles" cx="500" cy="500" r="25" fill="white" filter="url(#f1)" />
<script type="text/ecmascript">
<![CDATA[
setCoordinates(document.getElementsByClassName("circles"));
]]>
</script>
Run Code Online (Sandbox Code Playgroud)
这根本没有效果.但是,当我使用"getElementByID"并为圆圈分配ID时,它工作正常.(歌剧)
我多次做过以下事情:
<defs>
<filter id="screen">
<feBlend mode="screen" in2="BackgroundImage"/>
</filter>
</defs>
Run Code Online (Sandbox Code Playgroud)
但是,当我在一个形状内写下"filter ="url(#screen)"时,我的形状就消失了.我已经在每个浏览器中尝试过它(Safari,Chrome,Firefox,FfxNightly).我做错了什么?
如果有人能给我一个他们知道有效的例子,那将会很有帮助
谢谢
我有一个if else声明:
<script>
function myFunction()
{
var x="";
var myProb = Math.round(Math.random() * 1);
if (myProb<0.3)
{
x="Good morning";
}
else if (myProb<0.6)
{
x="Good day";
}
else
{
x="Good evening";
}
document.getElementById("demo").innerHTML=x;
}
</script>
Run Code Online (Sandbox Code Playgroud)
执行"if"和"else"位,但完全省略"else if"位."美好的一天"永远不会发生!
为什么是这样?我只是看不出我做错了什么.
javascript ×3
svg ×3
function ×2
svg-filters ×2
arrays ×1
attributes ×1
blend ×1
class ×1
document ×1
element ×1
get ×1
if-statement ×1
mode ×1
shape ×1