Home > Article > Web Front-end > Collection of some small applications of JQuery_jquery
1. var count = $("ul[@pid = '5']").length; if (count == 0); return "No"; return "Yes";
// Determine the UL of the page Is there any PID equal to 5? Generally speaking, do not use ELSE
2. this.mainUl.find("li").mouseover(function(i) { }); //Find all UIs in the UI , bind callback anonymous function
3.this.mainUl.parent().find("ul").each(function() { }); //Loop all UI of the parent node and execute callback anonymously Function
4.//Get the selected value of the drop-down menu
$(#testSelect option:selected').text();
Or $("#testSelect").find(' option:selected').text();
Or $("#testSelect").val();
5. $("#select").empty();//Clear the drop-down box
6. $("input[@type=checkbox][@checked]").val(); //Get the value of the first selected item of the check box
//Since the check box is generally selected There are multiple ones, so you can output them in a loop
$("input[@type=checkbox][@checked]").each(function(){
alert($(this).val());} );
$("#chk1").attr("checked",'');//Fill the attribute as unchecked
);//Fill the attribute as checked
if($("#chk1").attr('checked')==undefined)return 'unchecked';retuen 'selected'//Determine whether it has been checked Check
$('#select_id')[0].selectedIndex = 1;//The second element of the select drop-down box is the currently selected value (change the index value)
7. $("input[@type =radio][@checked]").val(); //Single selection group radio (get all RADIO values on the page):