Those at work (1), those at work

Source: Internet
Author: User

Those at work (1), those at work

1. toastr

Http://www.jq22.com/jquery-info476

2. jquery1.11.1 checkbox
Front-end js Code:

// Select all function CheckAll (e) {if ($ (e ). attr ("checked") = "checked") {$ (e ). removeAttr ("checked"); $ (": checkbox [name = 'cbxstudent ']"). removeAttr ("checked");} else {$ (e ). attr ("checked", true); // Add attribute $ (e ). prop ("checked", true); // equivalent to refreshing the page $ (": checkbox [name = 'cbxstudent ']"). attr ("checked", true); // Add attribute $ (": checkbox [name = 'cbxstudent ']"). prop ("checked", true); // equivalent to refreshing the page} // single-choice function CheckOne () {var checkNums = $ (": checkbox [name = 'cbxstudent '] "). length; // The total number of checkboxes var checkedNums =$ (": checkbox [name = 'cbxstudent ']: checked "). length; // The total number of checkboxes selected if (checkNums = checkedNums) {$ ("# cbxStudentAll "). prop ("checked", true); // equivalent to refreshing the page} else {$ ("# cbxStudentAll "). removeAttr ("checked ");}}

The checked attribute of the attr method is not changed, but the property of the prop method is changed, and the checkbox of the page is not checked. The combination of the two methods is normal, which may be a version issue.

3. jquery $. each ()

Var jsonClass = '{"classes": [{"classname": "Class 1", "classid": "1" },{ "classname": "Class 2 ", "classid": "2" },{ "classname": "Class 3", "classid": "3 "}';
$. Each (json. classes, function () {options + = "<option value = '" + this. classid + "'>" + this. classname + "</option> ";})

4. jquery's method of getting and setting outerhtml

$(".test").prop("outerHTML");$('.test').prop('outerHTML', '<input>');

5. Search for class! = "Sel" | class = "sel" a tag

$("#classList").find("a:not(.sel)");$("#classList").find("a.sel");

6. jquery concatenates json data

var jsonClass = '{ "classes": [';var jsonContent = "";$.each($ClassA, function () {    classname = $(this).text();    classid = $(this).attr("id");    classid = classid.substr(7, classid.length)    jsonContent += '{ "classname": "' + classname + '", "classid": "' + classid + '" }' + ",";});if (jsonContent.length > 0) {    jsonContent = jsonContent.substr(0, jsonContent.length - 1);}jsonClass += jsonContent + '] }'; var json = eval("(" + jsonClass + ")");

7. jquery select options

$("#select_classes option:selected").val();

8. Close button & times;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.