jquery里面的表单选择器

Original 2019-03-06 20:33:50 214
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><script src="./jquery-3.3.1.min.js"></script><script type

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<script src="./jquery-3.3.1.min.js"></script>

<script type="text/javascript">

//表单选择器

//语法

//$(':enabled')所有激活的input元素(可以使用的input元素)

//$(':disabled')所有禁用的input元素(不可以使用的input元素)

//$(':selected')所有被选取的元素,针对于select元素

//$(':checked')所有被选中的input元素

$(document).ready(function () {

// $(':enabled').css('background','pink')

// $(':disabled').css('background','red')

// $(':selected').css('color','blue')

$(':checked').parent().css('color','red')

})

</script>

</head>

<body>

<form action="">

输入框1 <input type="text" name=""><br>

输入框2 <input type="text" name=""><br>

输入框3 <input type="text" name="" disabled=""><br>

输入框4 <input type="text" name=""><br>

<select name="" id="">

<option value="">摩羯座</option>

<option value="" selected="">双鱼座</option>

<option value="">射手座</option>

<option value="">天蝎座</option>

</select><br>

爱好:

<label for=""><input type="checkbox" name="">看书</label>

<label for=""><input type="checkbox" name="" checked="">游泳</label>

<label for=""><input type="checkbox" name="">游戏</label>

</form>

</body>

</html>


Correcting teacher:韦小宝Correction time:2019-03-07 09:13:33
Teacher's summary:写的很不错 jQuery中的选择器种类也是蛮多的 但是总的来说选择器都很重要 常用的也就id class 以及表单选择器这几种

Release Notes

Popular Entries