Alright, I'm new to jQuery. I am still trying to get the hang of it...
The problem I have:
I have 2 textfields on a page (tbUsername and tbPassword), and want to manipulate them. When a user clicks or focusses on tbPassword i need to do the same. So instead of this:
$('tbPassword').click(function) () {
//do same code as onFocus
});
$('tbPassword').focus(function) () {
// do same code as onClick
}
I do this:
$('tbPassword').click(function) () {
handle_tbPassword_events(this);
});
$('tbPassword').click(function) () {
handle_tbPassword_events(this);
});
function hande_tbPassword_events(obj) {
// but, from this function i need to access tbUsername..
// $('tbUsername').value = 'something'; does not work, cannot access jQuery (i think)
}
So, what is the proper way to code this?
Should I create a global variable for tbUsername?
Should I create a global instance of '$'? (seems very wrong to me)
Can I combine 2 events in one expression? Something like: $('tbPassword').click(function).focus(function) { //do something } And in that case, how do I access the 2 events?
Or should I somehow "plug" my function to jQuery? Like extending jQuery?
Some help and/or suggestions are appreciated very much ..