0

i want add this to my html,but it didn't work .

var html = '<div id="youkuplayer"></div>'
+'<script type="text/javascript" src="http://player.youku.com/jsapi">'
    +'player = new YKU.Player("youkuplayer",{'
            +'client_id: "81dab93633c39ff0",'
            +'vid: "XNjQ4Nzk5MTA0_ev_1",'
            +'width: "240",'
            +'height: "200",'
            +'autoplay: false,'
            +'show_related: false'
        +'});'
    +'</script>';

$("#added_video").css("display","block").append(html);

but if i use a static html include this,it works.

sprite
  • 554
  • 1
  • 5
  • 11

2 Answers2

0

Some error in your code,you need add '</script><script>' in your code like this:

var html = '<div id="youkuplayer"></div>'
    +'<script type="text/javascript" src="http://player.youku.com/jsapi"></script><script>'
        +'player = new YKU.Player("youkuplayer",{'
                +'client_id: "81dab93633c39ff0",'
                +'vid: "XNjQ4Nzk5MTA0_ev_1",'
                +'width: "240",'
                +'height: "200",'
                +'autoplay: false,'
                +'show_related: false'
            +'});'
        +'</script>';
yoyo
  • 722
  • 6
  • 4
0

Your problem is the SCRIPT tag, which jQuery chokes on.

See this answer for some possible solutions: How to dynamically insert a <script> tag via jQuery after page load?

Community
  • 1
  • 1
S McCrohan
  • 6,663
  • 1
  • 30
  • 39