0
How do I load one script on a page, the result appears on a div
?
Example:
<script type="text/javascript">
/*
conteúdo do script
*/
</script>
<div id="script" class="000000"></div>
The goal is that the script when it is loaded into the page, its output appears where the div
is located.
I have an example here:
<div id="video" class="UJAwNkhbYWM"></div>
<iframe width="854" height="510" ID="caixa" frameborder="0" allowfullscreen></iframe>
<script>
var video = $("#video").attr('class');
$('#caixa').attr('src', "https://www.youtube.com/embed/" + video);
</script>
With this code it is possible to do this with a Youtube video, however I would like to run the same with a script. Trying to clarify a little more....
Let’s look at the example of Lightbox that is used to view images. That part of script:
$("a[href$='.jpg'], a[href$='.png'], a[href$='.jpeg'], a[href$='.gif']").fancybox();
Indicates that by clicking the script, and he finding images with the end, .jpg
, .png
and others it will make the desired effect.
In the case of a script I wanted him to be executed he do it in a div
specifies.
Like he finds the image .png
, but he’ll show her at Sidebar for example, why the script found the div
there.
You want to enter the result of a script or the code of a script that has been executed?
– Paulo Henrique
The result, the script executes a function, and the result appears in the div
– Endou
This is very relative, if such a script is simply printing right where it is, just put it into the div normally, but if it is modifying the content of a previously defined element, you can name the div with the same name, or identify the element the script used or created and move content to div using jquery.
– Jader A. Wagner
How did you get this to work?
– Sergio