javascript - How to change a mouseover event to a onclick one? -


here's want. there many words such test1, test2, test3, ... , each of them associated 1 or more examples. want show words side side, , have examples show when associated word "clicked" @ first, wrote below (mouseover event), realized doesn't work in mobile environments. need change plan. want action occur when user clicks word.

https://jsfiddle.net/kyubyong/umxf19vo/

html

<a>test1</a> <div class="divs">     <li>this example of test1</li> </div>  <a>test2</a> <div class="divs">     <li>this example of test3</li> </div>  <a>test3></a> <div class="divs">     <li>this example of test3</li> </div> 

css

a:hover {     background-color: lightgray; }  .divs  {   display: none; }  a:hover + .divs  {     display: block;     position: absolute;     background-color: lightgray;     width: 100%;     padding: 5px; } 

it looks event you're after click event.

i don't think can done using css in jsfiddle example, can done javascript.

this 1 way approach using jquery:

$('a').click(function() {  $('a').removeclass('active');  $(this).toggleclass('active'); }); 

see working example on https://jsfiddle.net/fznl3c9l/


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -