2016-03-01 45 views
0

此腳本用於調用jQuery的字幕調用jQuery函數

<script> 
    $(function() { 
     $('example3').marquee({ 
      gap: "0", 
      speed: "3000", 
      direction: "up", 
      duplicated: "true" 
     }); 
    }); 
</script> 

我想申請動態內容相同的腳本工作正常,對靜態內容在一個div我將從xml文件中獲取並使用js添加到div中。

從xml文件中獲取內容後,如何在我的js中調用此函數。

+0

您可能希望在加載項目後綁定事件。 – Mox

+0

檢查如何從XML中獲取數據http://stackoverflow.com/questions/10684145/how-to-retrieve-xml-data-from-javascript ..在回調方法中,您可以從xml中檢索值並使用它是你的方法 – gurvinder372

+0

運行php頁面後會顯示

0
$.ajax({ 
    url: "test.xml", 
    method: "GET", 
    success: function(data){ 
     $('example3').html(data).marquee({ 
     gap: "0", 
     speed: "3000", 
     direction: "up", 
     duplicated: "true" 
    }); 
    } 
}); 

希望這有助於!

0
<script> 
function functionName(){ 
    $('example3').marquee({ 
     gap: "0", 
     speed: "3000", 
     direction: "up", 
     duplicated: "true" 
    }); 
    } 
    $(document).ready(function(){ 
     functionName(); 
    }); 
</script>