zoukankan      html  css  js  c++  java
  • jQuery选择器之样式二

    prop()方法和attr()类似,但是HTML5规定有一种属性在DOM节点中可以没有值,只有出现与不出现两种,例如:

    <input id="test-radio" type="radio" name="test" checked value="1">
    <input id="test-radio" type="radio" name="test" checked="checked" value="1">

    attr()prop()对于属性checked处理有所不同:

    var radio = $('#test-radio');
    radio.attr('checked'); // 'checked'
    radio.prop('checked'); // true

    prop()返回值更合理一些。不过,用is()方法判断更好:

    var radio = $('#test-radio');
    radio.is(':checked'); // true

    类似的属性还有selected,处理时最好用is(':selected')

  • 相关阅读:
    HDU4126
    训练赛Day6-The 36th ACMICPC Asia Regional Beijing Site
    弦图
    HDU4821 字符串哈希+尺取
    HDU1854
    HDU1166
    输入输出挂
    LightOj 1027 数学期望
    HDU
    HDU
  • 原文地址:https://www.cnblogs.com/sunxirui00/p/7553030.html
Copyright © 2011-2022 走看看