Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to output youtube embedded videos with jquery toggle action?
    text
    copied!<p>I want to output youtube videos with a toggle on/off option by jquery on my website by retrieving youtube embed codes from my SQL table. I got the youtube videos to hide/display by clicking a button with javascript but I wanted the smooth transition that the jquery toggle action provides.</p> <p>Heres what I have so far:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;hide/show iframe&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/&gt; &lt;style type="text/css"&gt; &lt;!-- .frDocViewer { width:70%; height:50%; display:none; } --&gt; &lt;/style&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function(){ $("#button").click(function(){ $(id).toggle("slow"); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;?php mysql_connect ("localhost","","") or die(mysql_error()); mysql_select_db ("") or die(mysql_error()); $lastid = mysql_query ("SELECT * FROM embed ORDER BY id DESC LIMIT 1"); $lastid = mysql_fetch_assoc($lastid); $lastid = $lastid['id']; for ($count=1; $count&lt;= $lastid ; $count++) { $iframe = mysql_query ("SELECT * FROM embed WHERE id=$count "); $iframe = mysql_fetch_assoc($iframe); $iframe = $iframe['url']; echo " &lt;img src='utube.gif' id='button' /&gt; &lt;div id='$count' class='frDocViewer'&gt; $iframe &lt;/div&gt; "; } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload