.prop() VS .val() .Setting an input text value with jQuery

后端 未结 6 1584
栀梦
栀梦 2021-01-05 12:42

After reading (the interesting) .prop() vs .attr() and jQuery Performance : attributes doubt arise in my mind about what is better to use: .prop() or .val() ? I want to set

6条回答
  •  天涯浪人
    2021-01-05 12:59

    One more bug when using prop(). Under IE 11, the following code wouldn't set the value:

    var props = {'value':'test', 'type':'radio'};
    var input = $('').prop(props);
    $(document.body).append(input);
    

提交回复
热议问题