プロトタイプでの

他のヒント

あなたが頭の中にJavaScriptを含めたい場合は、あなたがこのような何かを行う可能性があります:

$$('head').first().insert({
    bottom: new Element('script', {
        type: 'text/javascript'
    }).update('function helloWorldToConsole(){console.log("Hello World!")}')
});

これは新しいSCRIPTタグを作成し、あなたの頭の下にそれを挿入します。あなたは、このように外部JavaScriptファイルを追加する場合でも、それは非常に良くなります:

$$('head').first().insert({
    bottom: new Element('script', {
        type: 'text/javascript',
        src: 'http://www.example.com/path/file.js'
    })
});

あなたはより後でスクリプト内の関数を使用することができます。

これを試して..

    $('<script></script>',{
     type:'custom',
     id:'script1'
    }).appendTo('head').attr('type','text/javascript');

    $('#script1').append(< add js code here >);

});

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top