:submit

Định nghĩa và sử dụng

  • Bộ chọn :submit: giúp chọn được thành phần input có thuộc tính type với giá trị submit.

Cấu trúc

  • Đã được thêm vào từ phiên bản 1.0
$(':submit')
$('input:submit')

Ví dụ

Html viết:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="https://code.jquery.com/jquery-latest.js"></script>
<style>
    span.bgChoose{
        background-color: blue;
        display: inline-block;
        width: 300px;
    }
</style>
<script>
$(function(){
    $(':submit').wrap('<span class="bgChoose"></span>')
});
</script>
</head>

<body>
<input type="button" value="Button input" /> type = button<br />
<input type="text" value=" type = text" /><br />
<input type="hidden" value="hidden" /> type = hidden<br />
<span style="display:none;">span display none</span> span display none<br />
<input type="file" /> type = file<br />
<input type="image" src="images/btn_submit.jpeg" /> type = image<br />
<input type="password" value="password" /> type = password<br />
<input type="radio" /> type = radio<br />
<input type="radio" checked="checked" /> checked<br />
<input type="radio" disabled="disabled" /> disabled<br />
<input type="text" value="type = text" /><br />
<input type="reset" value="Reset" /> type = reset<br />
<input type="submit" value="Submit" /> type = submit<br />
<input type="checkbox" /> type = checkbox<br />
<select>
<option>option01</option>
<option>option02</option>
<option>option03</option>
</select><br />
<textarea rows="5" cols="25">textarea</textarea><br />
<input type="checkbox" checked="checked" /> checked<br />
<input type="checkbox" selected="selected" /> selected<br />
<input type="checkbox" disabled="disabled" /> disabled<br />
<button>Button</button> tag button.
</body>
</html>

Hiển thị trình duyệt:

$(':submit') chọn tất cả các thành phần input có thuộc tính type với giá trị submit.