how i can check if div onclick="test(1)"
<div class="range" style="left:150px; background: url(/img.png) -106px 0" onclick="test(1)"><b>about 1:<br>info 1</b></div>
i arleady try use $_GET
but doesnt work
if($_GET['test(1)']){
do something doesn't work
}
You can not get onclick
value like that( $_GET
), but you can do something like this in javascript:
if(document.getElementById('myDiv').getAttribute('onclick') == "test(1)"){
console.log("True, your value is " + document.getElementById('myDiv').getAttribute('onclick'));
}else{
console.log("False, your value is " + document.getElementById('myDiv').getAttribute('onclick'));
}
<div id="myDiv" class="range" style="left:150px; background: url(/img.png) -106px 0" onclick="test(1)"><b>about 1:<br>info 1</b></div>
Just add Id to your element and check it with javascript. If you don't want to use id, you can do the same thing using Tag or Class name:
document.getElementsByClassName("range")[0].getAttribute('onclick');
document.getElementsByTagName("div")[0].getAttribute('onclick');
And about $_GET['test(1)']
:
$_GET
Is used for post and get methods which are used by <form>
elements:
<form method="GET" action="page.php"><input type="submit" value="submit"/></form>
</div>