0

イベントクリック後に表示したいのでラファエルセットにidを設定したいです。

これは私のセットです:

var divResult = document.getElementById('printResult');
var space2Draw = Raphael(divResult, 1600, 900);
var st = space2Draw.set();

st.push(
    space2Draw.circle(newXCoordinates, newYCoordinates, 20).click((function (valore) {
        return function () {
            window.open("index-point.html?id=" + (valore) + "&type=" + type + "&description=" + description + "&name=" + name);
        }
    }(valore))).mouseover(function () {
        this.attr({ 'cursor': 'pointer' });
        this.attr({ 'opacity': '.50' });
    }).mouseout(function () {
        this.attr({ 'opacity': '1' });
    })

            );

私のページにはボタンがあります:

function show(){
        var element = space2Draw.getById(-1);
        element.show();

    }
}

この方法で ID を設定することはできません: set.id = -1? ID を設定して、そのセットを見つけるにはどうすればよいですか?

助けてくれてありがとう。

4

2 に答える 2

2

を使用setAttribute()して、後でアクセスする要素の CLASS を追加してから、それらの CSS プロパティを変更してみてください。最初のステップは、各要素の CLASS を変更することです。

myElement.node.setAttribute("class", "class_name");

残念ながら、Raphael ではセットを一意の HTML オブジェクトとして扱うことができないため、セット全体に対して一度にこれを行うことはできません。代わりに、次のような for サイクルを使用して、セット内の各要素に対してこれを行う必要がある場合があります。

for (var i=0; i<st.length; i++) {
    st[i].node.setAttribute("class", "class_name");
}

次に、JQuery を使用して、作成した CLASS の CSS プロパティを変更し、セット内の要素を表示できます。

function show(){
    $('.class_name').css('display', 'block');
 }

これが役立つことを願っています。

于 2013-06-12T16:04:49.770 に答える