Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-24-2009, 01:18 AM   PM User | #1
wyclef
Regular Coder

 
Join Date: Feb 2005
Posts: 149
Thanks: 1
Thanked 0 Times in 0 Posts
wyclef is an unknown quantity at this point
Jquery hover

Hey, how do I get a jquery hover coded more efficiently than this so that the text also triggers the image hover as well. The way this is set up seems really crummy. heres the link

dynodealz.com/crum/crum.html

don't worry about the missing image.
wyclef is offline   Reply With Quote
Old 03-24-2009, 01:38 AM   PM User | #2
TinyScript
Regular Coder

 
Join Date: Mar 2009
Location: Portland Oregon
Posts: 690
Thanks: 44
Thanked 63 Times in 62 Posts
TinyScript is on a distinguished road
looks like you need to put the text into an anchor
<a>text</a>
TinyScript is offline   Reply With Quote
Old 03-24-2009, 01:42 AM   PM User | #3
wyclef
Regular Coder

 
Join Date: Feb 2005
Posts: 149
Thanks: 1
Thanked 0 Times in 0 Posts
wyclef is an unknown quantity at this point
it doesnt validate if i put heading tags within a link tag
wyclef is offline   Reply With Quote
Old 03-24-2009, 01:47 AM   PM User | #4
TinyScript
Regular Coder

 
Join Date: Mar 2009
Location: Portland Oregon
Posts: 690
Thanks: 44
Thanked 63 Times in 62 Posts
TinyScript is on a distinguished road
I see
put anchors in the h tags
<h2><a>text</a></h2>

edit: that doesn't work

Last edited by TinyScript; 03-24-2009 at 01:56 AM..
TinyScript is offline   Reply With Quote
Old 03-24-2009, 01:49 AM   PM User | #5
wyclef
Regular Coder

 
Join Date: Feb 2005
Posts: 149
Thanks: 1
Thanked 0 Times in 0 Posts
wyclef is an unknown quantity at this point
but i've got 2 sets of h tags. if i put anchors in both then i have to duplicate the same link.
wyclef is offline   Reply With Quote
Old 03-24-2009, 01:58 AM   PM User | #6
TinyScript
Regular Coder

 
Join Date: Mar 2009
Location: Portland Oregon
Posts: 690
Thanks: 44
Thanked 63 Times in 62 Posts
TinyScript is on a distinguished road
Quote:
Originally Posted by wyclef View Post
it doesnt validate if i put heading tags within a link tag
Quoted from somewhere on the internet:
that's not valid HTML -- even if many browsers will recover from the error. The anchor tag is an inline element, and it should not contain a block element such as a div, h1, p and so on.
TinyScript is offline   Reply With Quote
Old 03-24-2009, 02:05 AM   PM User | #7
wyclef
Regular Coder

 
Join Date: Feb 2005
Posts: 149
Thanks: 1
Thanked 0 Times in 0 Posts
wyclef is an unknown quantity at this point
ok, any other ideas?
wyclef is offline   Reply With Quote
Old 03-24-2009, 07:27 PM   PM User | #8
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Or you could always change the infoFade function to look like this:

Code:
	function infoFade() {	
		$('.picture a').hover(
			function () {
				$(this).find('strong').fadeIn('normal');
				},
			function () {
				$(this).find('strong').fadeOut('normal');
			}
		);
		$('h6').hover(
			function () {
				$('.picture a').find('strong').fadeIn('normal');
			},
			function () {
				$('.picture a').find('strong').fadeOut('normal')
			}
		)
		$('h5').hover(
			function () {
				$('.picture a').find('strong').fadeIn('normal');
			},
			function () {
				$('.picture a').find('strong').fadeOut('normal')
			}
		)
	}
Also, you don't need to have that function inside $(document).ready and can safely pull it out, and just leave the call to it in there. Enjoy.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 03-24-2009, 07:38 PM   PM User | #9
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
And yet another way to go about it is to just assign the hover function to the '.picture' class, instead of '.picture a', which would definitely remove the need to duplicate the code, though you will get hovers even when not over the text, but over the div itself. Or just use .each... like so:

Code:
	function infoFade() {	
		$('.picture div').children().each(function() {
			$(this).hover(
				function () {
					$('.picture a').find('strong').fadeIn('normal');
					},
				function () {
					$('.picture a').find('strong').fadeOut('normal');
				}
			)
		});
	}
But eh, whichever floats your boat. Enjoy.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 03-25-2009, 07:35 PM   PM User | #10
wyclef
Regular Coder

 
Join Date: Feb 2005
Posts: 149
Thanks: 1
Thanked 0 Times in 0 Posts
wyclef is an unknown quantity at this point
those look promising but i wasnt able to get either of those 2 to work...
wyclef is offline   Reply With Quote
Old 03-25-2009, 08:35 PM   PM User | #11
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Quote:
Originally Posted by wyclef View Post
those look promising but i wasnt able to get either of those 2 to work...
Very rarely do I post untested code. In this case, both options were tested with your mark-up. Upload a live version for me to diagnose and we'll see exactly where the problem is.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 03-25-2009, 08:59 PM   PM User | #12
wyclef
Regular Coder

 
Join Date: Feb 2005
Posts: 149
Thanks: 1
Thanked 0 Times in 0 Posts
wyclef is an unknown quantity at this point
thx. not sure what happened but i restarted by computer and now the code works fine... haha... weird.
wyclef is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:00 AM.


Advertisement
Log in to turn off these ads.