On Dec 2, 2007, at 10:47 AM, [EMAIL PROTECTED] wrote:


Hi :)
I enjoy jQuery :) but sometimes I have some problems. Could you help
me with one:
I add elements to page (on click)
jQuery("#div").append('<p>Tekst:'+tekst+</p>')

but when page have a lot of content (browser scrollbar is visible) and
page is scrolled to bottom and I click some link, <p>Tekst:'+tekst+</
p> is added to page but is one wrong thing, page is scrolling to the
top -  it's not good because user must scroll page down if he want add
<p>Tekst:'+tekst+</p> more than once.
So my question is: How can I avoid "page jumping to top" ?
Please help me :)

Hi Paul,

(I just replied to your off-list email to me with the following ...)

This line looks like it should have a quotation mark before the closing </p>:

jQuery("#div").append('<p>Tekst:'+tekst+</p>')

should be:

jQuery("#div").append('<p>Tekst:'+tekst+'</p>')

If you're binding the click handler to a link ( <a> ), you'll have to return false after the append line. I'm guessing that you're clicking on a link that has href="#". So it might look something like this:

 jQuery('a').click(function() {
   jQuery("#div").append('<p>Tekst:'+tekst+'</p>');
   return false;
 });

I hope that helps.

Reply via email to