Execute a css code when I click on an image

General questions about NeoAppBuilder - our rapid application development tool for building HTML5, web and mobile apps.

Moderator: Neosoft Support

Locked
Palamar
Posts: 161
Joined: Wed Apr 06, 2005 4:34 pm

Execute a css code when I click on an image

Post by Palamar »

Hi, Is there any way that when I click on an image it will execute a css code ?. I explain: I have an effect that by placing it in Application Properties> Styles, causes an image to rotate by mouseover (and indicating the ID). What I want is for the rotation to take place when the user clicks on the image. With the Rotate function of NeoAppBuilder does not work the same (it is very abrupt change), in contrast with the routine is much smoother. The problem is that CSS does not allow it, just visited or hover, and I would need something like onClic :)

Thank you!
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Execute a css code when I click on an image

Post by Gaev »

Palamar:
Is there any way that when I click on an image it will execute a css code ?.
I did a Google search using phrase javascript to change css ... and it returned http://www.w3schools.com/js/js_htmldom_css.asp ... so you can place appropriate javascript code in your Image Object's onClick event routine.

http://www.w3schools.com/jquery/css_css.asp shows you how to do this using jQuery (built into NeoAppBuilder).
I have an effect that by placing it in Application Properties> Styles, causes an image to rotate by mouseover (and indicating the ID). What I want is for the rotation to take place when the user clicks on the image. With the Rotate function of NeoAppBuilder does not work the same (it is very abrupt change), in contrast with the routine is much smoother. The problem is that CSS does not allow it, just visited or hover, and I would need something like onClic :)
Post the css that works with hover ... perhaps the same css can be setup for another class e.g. 'isClicked' ... and then the javascript code in the object's onClick event can just change the object's class to 'isClicked' ... of course, you will need another event to change the class back to something like 'isNotClicked'
Palamar
Posts: 161
Joined: Wed Apr 06, 2005 4:34 pm

Re: Execute a css code when I click on an image

Post by Palamar »

Hey, thanks. I have been able to do something by mixing css and js and it has worked. I will have to see that, instead of changing a single parameter, change the whole class (or execute one, for example, a class that has an animation). Regards!
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: Execute a css code when I click on an image

Post by Gaev »

Palamar:

jQuery provides functionality to perform a custom animation of a set of CSS properties. ...examples on this page ... http://api.jquery.com/animate/ ... might help you achieve your goals.
User avatar
luishp
Posts: 410
Joined: Wed May 23, 2007 10:17 am
Location: Spain
Contact:

Re: Execute a css code when I click on an image

Post by luishp »

Take a look at JQuery addClass() and removeClass() methods:
http://www.w3schools.com/jquery/jquery_ref_html.asp

Also try my "PowerApp" plugin as it has a lot of usefull functions.
Regards
Luis Hernández - SinLios Soluciones Digitales
http://sinlios.com
Palamar
Posts: 161
Joined: Wed Apr 06, 2005 4:34 pm

Re: Execute a css code when I click on an image

Post by Palamar »

Gracias a Luishp y Gaev por el dato, estoy viendo todo, desde ya he logrado lo que necesitaba con js...:)


Thanks to Luishp and Gaev for the data, I'm seeing everything, from what I already achieved what I needed with js ...
Locked