I am working on a slide show where I need to return a portion of HTML with a <script> tag and a piece of javascript function in it.I want to add it as I can have multiple slide shows and each one with different properties like transitions,slide speed etc.This function consists the parameters of the slider properties.
return '<div id="slider" class="nivoSlider">'+
'<div class="">'+
'<img id="" class="image mover" style="position:absolute;left:0px;top:0px;" src="http://localhost/gobiggi_VS_2_2/images/slideShow/slide01.jpg" data-thumb="images/slideShow/thumb/slide01.jpg" alt="" />'+
'</div>'+
'<div class="">'+
'<img id="" class="image mover" style="position:absolute;left:0px;top:0px;" src="http://localhost/gobiggi_VS_2_2/images/slideShow/slide02.jpg" data-thumb="images/slideShow/thumb/slide02.jpg" alt="" />'+
'</div>'+
'<div class="">'+
'<img id="" class="image mover" style="position:absolute;left:0px;top:0px;" src="http://localhost/gobiggi_VS_2_2/images/slideShow/slide03.jpg" data-thumb="images/slideShow/thumb/slide03.jpg" alt="" />'+
'</div>'+
'<div class="">'+
'<img id="" class="image mover" style="position:absolute;left:0px;top:0px;" src="http://localhost/gobiggi_VS_2_2/images/slideShow/slide04.jpg" data-thumb="images/slideShow/thumb/slide04.jpg" alt="" />'+
'</div>'+
'</div>'+'<script>$("#slider").nivoSlider({effect: "sliceDown",animSpeed: 500,pauseTime: 3000,startSlide: 0,controlNavThumbs: true,controlNavThumbsFromRel:true, pauseOnHover: true,manualAdvance: false});</script>';
The function inside setTimeout is the one I need to store inside the HTML
I tried to achieve it by storing it in a variable and attaching it inside the setTimeout().I used .toString() and .append() .html .text but the script directly runs or executes instead of storing it in the html structure.How can I just store the function inside the script tag in the HTML structure?
setTimeout()doesn't wait for other code. If code is not done yet, or has a bit of delay the code can collide.<script>tag in the page