So I have this code:
<a style="color:white" id="randomNo">Hello</a>;
I am using jQuery to get the value of it by using:
$('#randomNo').text();
Is there a way to get the value ("Hello") in PHP?
So I have this code:
<a style="color:white" id="randomNo">Hello</a>;
I am using jQuery to get the value of it by using:
$('#randomNo').text();
Is there a way to get the value ("Hello") in PHP?
@FewFlyBy here look (Note: this is just a example of using js var in php).
<div id="foo">Click Me</div>
$("#foo").on('click', function(event) {
event.preventDefault();
var randomNo= $('#randomNo').text();
// Ajax.
$.ajax({
url: "SAMPLE.php",
type: "post",
data: {
randomNo: randomNo
},
success: function(){
alert("success");
},
error:function(){
alert("failure");
}
});
});
on SAMPLE.php
get the value from $_POST['randomNo'];
This is just a sample. if want want you can send your value to php page like above.
Hi You have to extract the anchor tag then textContent will help you to fetch the text of anchor tag
Here is the sample stuff
$link = "<a href='test.php'>tester</a>";
$dom = new domdocument;
$dom->loadHTML($link);
foreach ($dom->getElementsByTagName("a") as $a) {
echo $a->textContent, "\n";
echo $a->getAttribute("href"), "\n";
}
Hope it helps.