Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I believe all you need to do is fire a change the style of the element you want to modify when particular events happen. Also, I changed the DOCTYPE to use HTML5. Give this a try:</p> <pre><code>&lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; div.sample1 { width:100px; height:100px; background:red; transition:width 2s; -moz-transition:width 2s; /* Firefox 4 */ -webkit-transition:width 2s; /* Safari and Chrome */ -o-transition:width 2s; /* Opera */ } div.sample1:hover { width:300px; } &lt;/style&gt; &lt;script type="text/javascript"&gt; function doStuff(obj,boolStateChange) { console.log('test'); if (boolStateChange==true) { obj.style.cssText = "width:300px;height:100px;background:green;transition:width 2s;-moz-transition:width 2s;-webkit-transition:width 2s;-o-transition:width 2s;"; } else { obj.style.cssText = "width:100px;height:100px;background:green;transition:width 2s;-moz-transition:width 2s;-webkit-transition:width 2s;-o-transition:width 2s;"; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; This example does not work in Internet Explorer.&lt;/p&gt; &lt;div class="sample1"&gt;&lt;/div&gt; &lt;p&gt;Hover over the div element above, to see the transition effect.&lt;/p&gt; &lt;br/&gt;&lt;br/&gt;&lt;br/&gt; &lt;div id="javaHover" style="background-color:green;width:100px;height:100px;" onMouseOver="doStuff(this,true);" onMouseOut="doStuff(this,false);"&gt;&lt;/div&gt; &lt;p&gt;Hover over the div element above, to see the Javascript transition effect.&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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