操纵SVG图像的属性

时间:2017-07-07 10:32:53

标签: javascript html css

我试图在onclick按钮后更改我的甲虫的“轮廓”(svg属性中的笔划),但是因为我没有看到我的代码示例中的任何错误它不起作用,为什么?

public static boolean isSherlock(int arr[]) 
{
    if (arr.length > 2) {
        int i = 1;
        for (; i < arr.length - 1; i++) {
            int k = 0;
            int rhs = arr[i + 1];
            int lhs = arr[i - 1];

            int j = arr.length - 1;

            // **In single iteration it is suming from left as well as from right**
            while (k < i - 1 && j > i + 1) {
                rhs += arr[j--];
                lhs += arr[k++];
            }
            // **************

            // If any elements remain
            while (k < i - 1)
                lhs += arr[k++];

            while (j > i + 1)
                rhs += arr[j--];

            // compare
            if (rhs == lhs && lhs != 0 && rhs != 0) {
                return true;
            }
        }
    }
    return false;
}

Link to my pen

1 个答案:

答案 0 :(得分:2)

您忘记了'click'标签周围的引号,因此它只是显示为未定义的变量。

这将有效

beetlebtn.addEventListener('click', function(){
  beetle.style.stroke="yellow";
});

链接:https://codepen.io/anon/pen/pwOWjy