如何使用Jquery產生輸入框的題是文字,程式碼如下:
<input type="text" id="input_test" value="請輸入文字,謝謝。" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
$(function() {
var inputEl = $('#inputID'),
defVal = inputEl.val();
inputEl.bind({
focus: function() {
var _this = $(this);
if (_this.val() == defVal) {
_this.val('');
}
},
blur: function() {
var _this = $(this);
if (_this.val() == '') {
_this.val(defVal);
}
}
});
})
</script>
此程式碼可以直貼至.html直接運行。
2012年12月5日 星期三
2012年6月19日 星期二
使用 Google AJAX Libraries API 載入 JQuery & JQuery UI
可以直接從Google載入JQuery & JQuery UI 的 JS 檔,真的很方便。
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" language="javascript">
google.load("jquery", "1.62");
google.load("jqueryui", "1.8.14");
</script>
數字部分為版本,可依版本更新來修改。
更詳細請參考以下介紹:
http://code.google.com/intl/zh-TW/apis/libraries/devguide.html
訂閱:
文章 (Atom)