作者aatty ()
看板Ajax
標題[問題] 初學JavaScript (已學過PHP)
時間Sun Jul 14 23:18:17 2013
各位大大好,小弟寫PHP
今天開始想碰一些Javascript的東西,但完全沒有概念和基礎
爬了一些文 想試著寫些簡單的東西就馬上遇到問題,手邊也沒有工具書可參考
故請教版上高手們..... 我抄寫了一個按鈕的程式,按了之後會show出Hello 的字樣
但只會出現按鈕,按了之後不會有字樣(檔案存成HTML 用notepad++寫的)
程式碼如下...
<html>
<head>
<title>jQuery Tutorial 1</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
function showMsg() {
$('#msg').html('<h1>Hello</h1>');
}
</script>
</head>
<body>
<div id="msg"></div>
<input type="button" value="Click Me" onclick="showMsg()" />
</body>
</html>
檔案放在appserv的www根目錄資料夾,另外我有下載jquery-1.2.1.min
下載之後不知道要放在哪...@@a 很抱歉問愚蠢問題
但還請各位能幫幫我><
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 118.166.161.21
1F:→ cold514:src="jquery.min.js" 改成 jquery-1.2.1.min 看看 07/14 23:22
2F:→ cold514:jquery-1.2.1.min 跟你的PHP檔 放在同一個目錄 07/14 23:24
3F:→ aatty:天阿真是感謝您~~~~~ 07/14 23:25
4F:→ cold514:src = source 可以寫相對路徑或絕對路徑 07/14 23:30
5F:推 s25g5d4:初學最好學好一點的做法 不要用on click 07/14 23:30
6F:→ cold514:P.S jquery現在已經出到v1.10.3囉 07/14 23:32
7F:推 s25g5d4:給 button 一個 id 用$(button_id).on('click', showIng) 07/14 23:32
8F:→ s25g5d4:哇咧 手機又自動亂訂正了 是showMsg 07/14 23:33
9F:→ aatty:s25g5d4大寫的我還看不懂XD cold514大感謝您~ 07/14 23:42
10F:推 qwer820404:dynamic binding event 07/15 07:57
11F:→ a60301:<input type="button" id="btnShowMsg" value="Click Me"/> 07/19 03:35
12F:→ a60301:<script> $("#btnShowMsg").click(function () { 07/19 03:36
13F:→ a60301: $('#msg').html('<h1>Hello</h1>'); 07/19 03:37
14F:→ a60301:} </script> 07/19 03:37