0

IDを要素として使用するプロトタイプのツールチップを使用しています。1ページにツールチップがたくさんあるので、同じIDを1ページに2回以上使用することはできません。IDの代わりにCLASSを要素として使用する方法はありますか?これが私が持っているものです。

<div style="margin-right: 2px" id="tooltip_bio" class="">Learn More</div>
        <script type="text/javascript" language="javascript">
            new Tip('tooltip_bio', "Tooltip Content", {
                title: "Bio",
                closeButton: true,
                showOn: 'click',
                hideOn: { element: 'closeButton', event: 'click'},
                stem: 'bottomMiddle',
                hook: { target: 'topMiddle', tip: 'bottomMiddle' },
                offset: { x: 0, y: -2 },
                width: '300px'
            });
       </script>
4

2 に答える 2

1

プロトタイプのドキュメントから、次のようなことができます。

document.observe('dom:loaded', function() {
  $$('a[rel]').each(function(element) {
    new Tip(element, element.rel,{
        title: "Bio",
        closeButton: true,
        showOn: 'click',
        hideOn: { element: 'closeButton', event: 'click'},
        stem: 'bottomMiddle',
        hook: { target: 'topMiddle', tip: 'bottomMiddle' },
        offset: { x: 0, y: -2 },
        width: '300px'
    });
  });
});
于 2012-08-09T15:28:39.113 に答える
1

にはあまり詳しくありませんprototypejsが、ID が必要な場合は、ID を配列に入れて繰り返します。

;["id_1", "id_2", "id_3"].each(function(id, i) {

    new Tip(id, "Tooltip Content", {
        title: "Bio",
        closeButton: true,
        showOn: 'click',
        hideOn: { element: 'closeButton', event: 'click'},
        stem: 'bottomMiddle',
        hook: { target: 'topMiddle', tip: 'bottomMiddle' },
        offset: { x: 0, y: -2 },
        width: '300px'
    });

});
于 2012-08-09T15:06:49.410 に答える