I am new in jquery and I am suffering from such a problem which is a little weird after creating a div in jquery Can not use it, this example will show you how the problem is! Let's suppose that get.php is just in the page: echo "Test Test"; Code in my file:
& lt; Script type = "text / javascript" src = "jquery.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ("# bda"). Click (function () {$ .post ("get.php", function (data) {$ ("# tdiv"). ' & Lt; div class = "info" & gt; '+ data +' & lt; / div & gt; ');});}) $ (". Info") Click (function () {warning ("done");});}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "bda" & gt; Click here & lt; / Div & gt; & Lt; Div align = "center" style = "border: 1px solid blue" id = "tdiv" & gt; Example & lt; / Div & gt; & Lt; Div class = "info" & gt; It works here & lt; / Div & gt; Can someone help me ..
JQuery does $ (". Info") with you are selecting .info elements while calling it - which is only one element, because the other Later AJAX). No other click event is attached to that element. Therefore, the .info selector is not actually saved - only the element is removed from the document and then the selector is released. What do you want to do when you click on a selector a selector against jQuery you can do this with Event Delegation: // When you click on a place in the body, jQuery will check whether you click on the `` .info` element and execute the function in that condition. // It also works for later added elements. $ ("Body"). ("Click", ".info", function () {...});
Comments
Post a Comment