2017-06-02 42 views
-2

我的網站下載框現在如何設置Java我的鏈接

<div class="linkdl"> 
<?php 

$dl_320 =get_post_meta($post->ID, 'dl320', true); 

?> 
<?php if(!empty($dl_320)) { echo '<a href="'.$dl_320.'">Download MP3 </a>'; } ?> 

</div> 

如何設置代碼

<input id="button" type="submit" name="button" onclick="myFunction();" value="enter"/> 

<script> 

    function myFunction(){ 
     alert("You button was pressed"); 
    }; 

</script> 
+2

你能澄清這個問題好嗎? – Scott

回答

0

我從你的問題知道你正在嘗試這樣的:

<? 
php if(!empty($dl_320)) { 
echo "<a href='".$dl_320."' onclick='return myFunction();'>Download MP3 </a>"; 
} ?> 
<script> 
function myFunction(){ 
alert("You button was pressed"); 
}; 
</script> 
+0

HTTP錯誤500站點wp-admin/theme-editor.php?file = single.php – sanja

+0

添加後您收到錯誤? – lalithkumar

+0

是\t 加入後 – sanja

0

您需要將功能附加到事件。

例如:

<script> 
    function myFunction(){ alert("You button was pressed"); }; 

    jQuery('a').click(myFunction); 
</scrip>