<li class="list">fruit</li> <li class="list">vegetables</li> <li class="list">protein</li>
而且,我想找到最后一个列表项,从中获取文本,然后将其分配给PHP变量,以便:
<?PHP $variable = 'protein'; ?>
我对如何将它变成PHP变量很模糊?
$.post("script.PHP",{ value: $(".list:last").text() },function (result) { alert(result); // alerts whatever comes from the PHP script });
PHP方面
print strtoupper( $_POST["value"] );