带有html id的If语句


If statement with html id

我有下面的代码,如果有的话,它会得到一个id,并要求您单击一个按钮来显示数据。

<input type="text" id="date" value="<?php echo $_GET['id']?>" class="css-input" placeholder="Posting Date..." readonly="readonly" /><br /><br />    
<input type="button" id="validate" value="Let's get to work!" class="btn" /> 

下面的代码将自动带您到数据,如果那里有id,则无需单击按钮。:

jQuery(document).ready(function() {
    jQuery("#validate").click();
});

我怎么能做一个if语句,如果#validate不是null,然后执行jQuery代码,否则不要。怎么做呢,每次做<?php if(#date != null),我都有错误,有什么想法吗?

<?php 
if($_GET['id'] != NULL){
?>
<script>
 jQuery(document).ready(function()
 {
 jQuery("#validate").click();
 });
</script>
<?php }?>
</head>