[jQuery] $('*').not(':text').click(function() { $(':text').eq(2).focus() } ) ; wrong syntax?
Hi,
Basically, I would like to select all elements apart from text boxes.
When the elements (apart from text boxes) are clicked, the focus
should go to the last text box.
I have come up with this code:
$('*').not(':text').click(function() { $
(':text').eq(2).focus() } ) ;
However, the text boxes are *not* excluded from the selection - focus
goes to the last text box when *any* element (including text boxes) is
clicked.
Thanks for any help.
Paul Jones
Here is the full code :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd">
<html>
<head>
<title>CSS Selectors</title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<style type="text/css">
input { width : 70px ; }
#focusHere {width: 300px ; }
</style>
<script type = "text/javascript" src="jquery.js"></script>
<script type = "text/javascript">
$(document).ready(function()
{
// *THIS IS THE PROBLEM LINE* //
$('*').not(':text').click(function() { $
(':text').eq(2).focus() } ) ;
});
</script>
</head>
<body>
<ul>
<li>click on any list item to send focus to last text box</li>
<li>click on any list item to send focus to last text box</li>
</ul>
<form>
<input type='text' class='test'>
<input type='text'>
<input type='text' value = 'focus is switched to this box'
id='focusHere'>
</form>
</body>
</html>