JQuery學習筆記 如何使用JQuery

2021-05-23 17:04:41 字數 615 閱讀 6719

$的意思是jquery = window.jquery = window.$=$,因此jquery(document)=$(document) document是網頁中的物件,這裡指代整個網頁內容。

獲取乙個class的方法jquery(".someclass").css("border", "1px solid red")

獲取乙個id的方法jquery("#someid").html("so bold!")

$(document).ready(function());

相當於window.onload = function() 但是前者只要as soon as the dom (document object model) is ready, the code inside of the ready(function(){}) will start.

新增乙個mouseover和mouseout事件:$('a.afflink').mouseover(function())

.mouseout(function());

等同於$('a.afflink').mouseover(function());

$('a.afflink').mouseout(function());

jquery學習筆記

判斷checkbox是否被選中if attr checked true 檢查元素是否存在 if tt length 0 if tt 0 檢查元素是否隱藏 alert dvtest is visible 判斷元素顯示或隱藏狀態 多選框操作 獲取一組radio被選中項的值 var item input ...

Jquery 學習筆記

text 和 val 的區別 text 方法是取得所有匹配元素的內容。結果是由所有匹配元素包含的文字內容組合起來的文字。這個方法對html和xml文件都有效。獲取span,div p之類才用text 或html 方法。例子 b a p text 將得到 ba 單行文字不能用text 方法獲得值,必須...

Jquery學習筆記

1.給一組相同的css加事件,要使用bind,live在新的版本已經過期。testcss bind click function e else 未選中 3.改變checkbox選中狀態 mycheckbox prop checked true mycheckbox prop checked fals...