0
我是新來創建wordpress小部件,我想創建一個小部件,它將上傳一個圖像,並將其顯示在網站的首頁,爲了這件事我寫了下面的代碼,但在我的代碼中,javascript沒有正常運行,下面的代碼是在WP_My_Widget類和default-widgets.php文件中寫入的,實際上,當我嘗試提醒已加載文件的計數時,javascript代碼未運行,因此它只顯示我0.Javascript in wordpress
public function form($instance) {
// outputs the options form on admin
?>
<br/>
Please Enter The URL of Leading Site: <input type='text' name='url' id='url'/><br/>
Upload new image: <input type='file' name='images' id='images'><br/>
<br/><a href='javascript:void(0);' id='myid' onclick='abc();'>Proceed Uploaded File!</a>
<script>
function abc(myurl){
myLocalFiles = document.getElementById('images');
len = myLocalFiles.files.length;
alert(len);
}
</script>
<?php
}