Ich have the following site with JQuery:
<html>
<head>
<title>Testpost</title>
<script type="text/javascript" src="../jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var sendtest = $("#sendtest");
sendtest.keyup(function(){
$.post(
"test.php",
{ nur: sendtest.val() },
function(data) {
$('#receivetest').html(data);
}
);
});
});
</script>
</head>
<body>
<input type="text" name="season" id="sendtest"/>
<div id="receivetest"></div>
</body>
</html>
And following test.php:
<?php
$nur = $_POST['nur'];
echo $nur;
?>
<p id="hello">Hello World!</p>
Now I want to see on the receivetest-div only echo $nur; ! What must I do for that?
It is not a good practice to code like this. It would be better to add a parameter in your PHP file which will hide the div when you don't need it.
However, you can hide the div like that:
$('#receivetest').find('#hello').hide();
This will keep the html of the <div id="hello"> and its content, and hide it to the client.
You can also remove the div by doing this:
$('#receivetest').find('#hello').remove();
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