1
中規模および開始ユーザーが簡単です。イベントが完了した後にjqueryスクリプトをロードする
HTML::次のファイルを考える方法で、以前と呼ばれる別のページから
<html>
<head>
<script>
$(document).ready(function()
{
$("#fashion").onclick(function()
{
$get("ajax.php", { section: fashion}, function(result)
{
$("#container").html(result);
});
});
$("div").click(function()
{
var identification = $(this).attr("id");
alert(identification);
});
});
</script>
</head>
<body>
<div id="fashion">
Click me
</div>
<div id="container">
<div>
<div id="test">
Test
</div>
</body>
</html>
私が取得したHTML情報 "ajax.php"
<?php
if($_GET['fashion'])
{
?><div id="fashion_content">This is a random text</div><?php
}
?>
事は、関数$であることです( "div")。click(function ...スクリプトセクションでは、ajax getメソッド(div id = "fashion_content")で生成されたdivからidを返しませんが、他のもの( "fashion"、 "container "、" test ")。 一方、divの後にjquery関数を置くとそれを次のようにajax.phpファイルで動作します。
<?php
if($_GET['fashion'])
{
?><div id="random">This is a random text</div>
<script>
$("div").click(function()
{
var identification = $(this).attr("id");
alert(identification);
});
</script>
<?php
}
?>
私はGETイベントが完了した後にスクリプト(または唯一の機能)をリロードする必要が推測します。しかしどうですか?
速いバディだった!ありがとう! –