Wednesday 15 May 2013

Jquery Ajax load a div inside a file -


I try to load with jQuery and Ajax which is in another file. I can load the hole file, I can load a div with a text inside that file, but I can not load a single plain alone. Why?

index.html:

  $ (function () {$ ("# linkjax"). Click (function (e) {e.preventDefault (); $ ("Extern.html #red");})}}   

This works:

  $ ("Target to #") load (. "Extern.html"); $ ("#target") Load ("extern.html # text1");   

This does not work:

  $ ("# target"). Load ("extern.html #red");   

extern.html: & lt; Div id = "text1" & gt; Text & lt; / Div & gt; & Lt; Div id = "red" & gt; & Lt; / Div & gt; # Lesson1 {status: absolute; Top: 200px; Left: 200px; } #red {Status: Completed; Top: 50px; Left: 50px; Width: 100px; Height: 100px; Background: Red; }

This is extern.html:

red div in CSS should have some content, however, should be placed on the index.html file. CSS can not be applied from an external file, because you load only one part of the external page (#red).

No comments:

Post a Comment