您不能仅通过jQuery来完成;您将需要结合使用Ajax(可以使用jQuery完成)和PHP后端。一个非常简单的版本可能如下所示:
HTML:
<img src="img.jpg" /><img src="img2.jpg" /><img src="img3.jpg" />
Javascript:
$("img.foo").onclick(function(){ // Get the src of the image var src = $(this).attr("src"); // Send Ajax request to backend.php, with src set as "img" in the POST data $.post("/backend.php", {"img": src});});
PHP(backend.php):
<?php // do any authentication first, then add POST variable to session $_SESSION['imgsrc'] = $_POST['img'];?>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)