Use a variable to keep track of the appearance of the new tag you're adding. Your focus() event should add 1 to the variable,and check the variable. If the variable is non-zero before its incremented, the message is already there, don't add it again.
Then of course your blur() function should set the variable to 0, and remove the message. On Sep 13, 3:49 am, yo2lux <[EMAIL PROTECTED]> wrote: > I have this code to insert an HTML tag before an input field (input > type="text" id="edit-title"). > > var myText = '<div id="msg">This is a message</div>'; > > $("#edit-title").focus(function() { > $(this).before(myText); > > }); > > $("#edit-title).blur(function() { > $(".nodemsg").remove(); > > }); > > Sometimes the focus event is called twice, for example if browser > window is resized (firefox 3). Is possible to solve this problem ? I > need to check if myText is inserted before focus event ? > > Thanks!