Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Playing with jQuery

Featured Replies

Hello Friends

 

I'm new to jQuery, I've quickly read some stuff and attempted to duplicate, here's my code:

 

$(document).ready(function(){
  $("about").mouseover(function(event){
	alert("OY !!");
  });
});

 

And here's what #about is:

 

<li id="about"><a href="#" class="about">About</a></li>

 

I move my mouse over the <li> and nothing happens ! I do not get the alert box !

 

I would greatly appreciate any help.

 

PS. the alert is just to make sure things are working as they should before I move onto what I really need doing.

 

Thank You.

  • Author

Huh silly me :blush1:

 

Thank You Renaissance Design :drinks:

 

Now that I know that is working, I went to the jQuery website and searched for Rotate. Cause when a user moves the mouse over the <li> tag I want the thing slightly rotated.

 

If it isn't in the jQuery library, how can I rotate it slightly ?

 

Thanks

  • Author

Good thinking Pedro, I did not think of that ! Will it allow animating too ?

 

Either way, I can't get it to work :(

 

$(document).ready(function(){
  $("#about").mouseover(function(event){
	$(this).css(-webkit-transform, rotate(-90deg));
  });
});

  • Author

Never mind, the above, I didn't know the css property and value had to be in quotes.

 

This works:

 

$(document).ready(function(){
  $("#about").mouseover(function(event){
               $(this).css("-webkit-transform", "rotate(-90deg)");
  });
});

 

But not animated, so it flips very fast. I'll check out the animate method.

  • Author

Wow cool !! Thanks Pedro.

 

I was actually going through with this tutorial regarding the animating bit. And I got my code to be like so:

 

$(document).ready(function(){
  $("#about").mouseover(function(event){
	$(this).animate({
		'-webkit-transform' : 'rotate(-15deg)'
	  }
	);
  });
});

 

Unfortunately it isn't working, what's the reason behind why my way of doing it is not working ?

Hmmm, not sure, but you might have to also include jQuery UI for your animate to work.

It's probably best to do it using CSS though man, it doesn't make sense doing a CSS rotate via jQuery.

  • Author

Thanks Pedro, I have my code as follows now:

 

$(document).ready(function(){

// When cursor moves onto the <li>
  $("#about").mouseover(function(event){
	$(this).css({

	'-webkit-transition': '200ms all ease-in-out', 
       'webkit-transform': 'rotate(-10deg)',
	'-moz-transition' : '0.2s ease-in-out',
	'-moz-transform' : 'rotate(-10deg)'

	});
  });

  // When cursor moves away from <li>
  $("#about").mouseout(function(event){
	$(this).css({

	'-webkit-transition': '200ms all ease-in-out', 
       'webkit-transform': 'rotate(0deg)',
	'-moz-transition' : '0.2s ease-in-out',
	'-moz-transform' : 'rotate(0deg)'

	});
  });
});

 

Is there a CSS3 property for also making the box inflate slightly ? i.e. get bigger a bit, and also rotate, then deflate to original size ?

 

Thanks so much.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.