随笔分类 - JQuery
jQuery-对Select的操作集合
摘要:1. $("#select_id").change(function(){//code...}); //为Select添加事件,当选择其中一项时触发2. var checkText=$("#select_id").find("option:selected").text();//获取Select选择的Text3. var checkValue=$("#select_id").val();//获取Select选择的Value4. var checkIndex=$("#select_id ").get(0).selectedIndex;//获取Select选择的索引值5. var maxIndex
阅读全文
jquery 层级选择器
摘要:prev + next 匹配所有紧接在prev元素后的next元素(紧接的第一个匹配元素)prev ~ siblings 匹配prev元素之后的所有siblings元素$("form input"):匹配form内的所有input元素$("form, input"):匹配form和input元素(input元素包括form中的)$("form > input"):匹配form第一inpu...
阅读全文
end andSelf 区别
摘要:$(document).ready(function(){jQuery.fn.showTags=function(n){vartags=this.map(function(){returnthis.tagName;}).get().join(",");$("b:eq("+n+")").text(tags);returnthis;};$("p").showTags(0).find("span").s...
阅读全文
filter find 区别
摘要:jquery的filter将在一组已经选取的元素里面选择jquery的find将在一组已经选取的元素的子节点里面选择find()查找的是子孙、children()查找的是子女元素<div class="peanuts"> <p class="elephants"></p></div><div class="elephants"> <p></p></div>$('div').filter('.elephants'
阅读全文
浙公网安备 33010602011771号