Basically, I have a list:
<li class="list">fruit</li>
<li class="list">vegetables</li>
<li class="list">protein</li>
And, I want to find the last list item, get the text from it, and then assign it to a php variable, so that:
<?php
$variable = 'protein';
?>
I'm fuzzy on how to get it into a php variable?
$.post("script.php", { value: $(".list:last").text() }, function (result) {
alert(result); // alerts whatever comes from the php script
});
print strtoupper( $_POST["value"] );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With