Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Easy JQuery - why doesnt it work?
Old 03-05-2010, 08:20 AM Easy JQuery - why doesnt it work?
TWD
TWD's Avatar
King Spam Talker

Posts: 1,190
Trades: 0
I just want to create a simple script that gives two alert messages
one on mouseover / one on mouseout

Code:
$('input').bind('mouseover', function (){ alert("Hello"); });
    $('input').bind('mouseout', function (){ alert("Goodbye"); });
What am I doing wrong?
Any JQuery pros out there?
TWD is online now
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-05-2010, 08:47 AM Re: Easy JQuery - why doesnt it work?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
I don't see anything wrong with what you've written. However, if you want to bind events to both the over and out state event, it is easier to use the jQuery.hover() shortcut:
Code:
$('input').hover(function() {
    alert('Over');
},
function() {
    alert('Out');
});
Are you doing anything else wrong with your page? Is the path to jQuery correct? Is the code in correct placement to have an affect on the INPUT elements you intend to target? Is it either below them or inside of a $(document).ready()?
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 03-05-2010 at 08:49 AM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 03-05-2010, 10:03 AM Re: Easy JQuery - why doesnt it work?
TWD
TWD's Avatar
King Spam Talker

Posts: 1,190
Trades: 0
Oops. Looks like it was "ye old caching" trap.
It does actually work.

But good to learn about the hover event!!
Will try that next.
TWD is online now
Reply With Quote
View Public Profile
 
Old 03-05-2010, 10:21 AM Re: Easy JQuery - why doesnt it work?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Yeah, that will do it. I clear mine regularly, as you probably do.
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 03-05-2010, 10:54 AM Re: Easy JQuery - why doesnt it work?
TWD
TWD's Avatar
King Spam Talker

Posts: 1,190
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
I don't see anything wrong with what you've written. However, if you want to bind events to both the over and out state event, it is easier to use the jQuery.hover() shortcut:
Code:
$('input').hover(function() {
    alert('Over');
},
function() {
    alert('Out');
});
Are you doing anything else wrong with your page? Is the path to jQuery correct? Is the code in correct placement to have an affect on the INPUT elements you intend to target? Is it either below them or inside of a $(document).ready()?
So that works.

OK. Now I really need some help.
This is what I want to do:
I have a form with input fields and those fields all have "title" attributes.
For reasons which arent important to this discussion I can't get rid of the
"title" attributes themselves, but I don't want the tooltips to show on hover.
To best of my knowledge there is no way to suppress tooltips using CSS.

So that leaves a JQuery solution.
What I want to do is to remove the "title" attribute on hover (so there is nothing for the tooltip to show) but put it back again on hoverout.

So in the above example, in place of alert('over') and alert('out') what should I substitute?

I figure that the title needs to stored as a variable at some point.
But is it possible to pass that variable to the other part of the function, the part that puts the "title" attribute back in place?
TWD is online now
Reply With Quote
View Public Profile
 
Old 03-05-2010, 12:02 PM Re: Easy JQuery - why doesnt it work?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,987
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Code:
var titleMem;
$('input').hover(function() {
    titleMem = this.title;
    this.title = '';
},
function() {
    this.title = titleMem;
});
Variables declared outside of functions are available inside of functions, and if modified inside of the function without being declared with a "var" prefix, will be modified in the scope that encloses the function, whether it is global or local to another closure (function).
__________________
I build web things. I work for the startup
Please login or register to view this content. Registration is FREE
.

Last edited by wayfarer07; 03-05-2010 at 12:05 PM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Easy JQuery - why doesnt it work?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24771 seconds with 12 queries