I have written 1-2 jquery plugins but all of them fails when i try to use multiple instances....i didnt find any solution. Please take a look at below code, if u create 2 instances on this plugin its not working....whats wrong with this code. what makes plugin able to run multiple instances ??
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
</head>
<script src="jquery.js"></script>
<script>
(function($){
$.fn.truncate = function(options) {
return this.each(function() {
obj = $(this);
var body = obj.html();
$(obj).focus(function(){
alert($(obj).attr("id"));
});
});
};
})(jQuery);
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
$().ready(function(){
$('#t1').truncate();
$('#t2').truncate();
});
//-->
</SCRIPT>
<body>
<input type="text" id="t1">
<input type="text" id="t2">
</body>
</html>