popup balloon in JQuery
I used the following command to make a popup balloon each time mouse move on a div tag in a web page and I am trying to insert this command in any web page I am parsing so I append the command in the head as follows:
head.append("$('div').attr('onmouseover', 'balloon.showTooltip(event,You are hovering, I said click me! <开发者_运维技巧a href=www.google.com>Click</a>)');");
where ballon is the object I defined it previously
But it does not work
Besides not understanding what the question really is, there are a lot of things wrong with this code. The main issue I see is that the showTooltip function call is not legal javascript because the message is not a quoted string. In addition, this is not a good way to use event handlers in jQuery. Assuming that head is a jQuery object in your page (and not the head tag), try this:
head.append($("<div class='test'>").mouseover(function() {
balloon.showTooltip(event, "You are hovering, I said click me! <a href='http://www.google.com'>Click</a>");
});
The other issue with this is that the <div>
that you create and append to the page has no size so you can never get a mouseover event on it. If you give it a finite size, it can work. You can see that here: http://jsfiddle.net/jfriend00/Y6LGT/ where I give it a class name and use CSS to give it a size.
精彩评论