1. 程式人生 > >7.1.6 DOM對象屬性操作

7.1.6 DOM對象屬性操作

move ons console tel doc get att ole elements

prop() removeProp()

$(function(){

  //js對input單選按鈕checked的默認設置

  //console.log($(‘input[type=radio]‘).attr(‘checked‘)); //check

  var oInput=document.getElementsByTagName(‘input‘)[1];

  console.dir(oInput);

  console.log($(‘input[type=radio]‘).eq(0).prop(‘checked‘)); //獲取屬性

  $(‘input[type=radio]‘).eq(0).prop(‘aaa‘,‘11111‘) //設置屬性

  $(‘input[type=radio]‘).eq(0).removeProp(‘aaa‘) //刪除屬性

})

7.1.6 DOM對象屬性操作