I am using the following jquery code in my application..
the idea is to click a button when the user comes of a form and clicks any button on the screen..
<script>
$(document).ready(function() {
$('form').focusin(function() {
$(this).addClass('focused');
});
$(':not(form)').bind('click', function(e) {
if (!$(e.target).parents('form.focused').length) {
form.getElementById("customerdetails").click();
}
});
});
</script>
this script works fine in forefox but this is extremely slow in IE6…may i know the reason for this?? does it work faster in IE8…any ideas??
please suggest to improve this in IE6
many thanks in advance,
Jack.
Writing
$(':not(form)').bind('click', ...)will loop through every element in the document except the<form>tags and add a separate click handler to each one.This can be extremely slow.
Instead, you should add a single
clickhandler to the document and check whether the click originated inside a<form>tag, like this: