How to add JavaScript onclick function to HTML a href in PHP

1 Answer

0 votes
$url = "collectivesolver.com";
$differenturl = "http://seek4info.com/";
$title = "click";

$s = "<a href='$url' onClick=\"this.href='$differenturl'\">$title</a>";

echo $s;


/*
run:

<a href='collectivesolver.com' onClick="this.href='http://seek4info.com/'">click</a>

*/

 



answered Aug 21, 2020 by avibootz
...