tags:

views:

88

answers:

2

Hi friends,

I have created a page, in that - after loading a content the jquery is not working properly.

Problem :

  • Initially i have a div "content" which having some text
  • by clicking a button some content will load into the div "content" from div "temp" using
    $("#content").html($("#temp").html())
  • After loading this content the functionality of jquery (which i have already written in the new content) is not working.
  • Why its happening like this, its working fine in mozilla firefox but not IE, some times some unwanted values are appending into the new content tags
    such as done10="12"
    jQuery123654067531="18"
    jQuery123654067531="19"

Please clear this problem.

A: 

I think you should do this instead, it might solve your problem:

$("#content").append($("#temp"));

Let me know if that helped.

DrJokepu
A: 

If you're binding events to objects in jQuery using .bind() or .click(), etc., try the new ".live()" function instead. If you add more classes of similar, they too will now get the events attached to them.

How to use this live() function - please explain
praveenjayapal
instead of say $(".something").bind("click", function(){}) use $(".something").live("click", function(){}) so that way anytime another DOM objectis added that also satisifies the selector ".something", it also gets the click event added to it.