.опоры() и attr, который()



так jQuery 1.6 имеет новую функцию prop().



$(selector).click(function(){
//instead of:
this.getAttribute('style');
//do i use:
$(this).prop('style');
//or:
$(this).attr('style');
})


или в этом случае они делают то же самое?



а если я do нужно переключиться на использование prop(), все старые attr() звонки прервутся, если я переключусь на 1.6?



обновление






selector = '#id'

$(selector).click(function() {
//instead of:
var getAtt = this.getAttribute('style');
//do i use:
var thisProp = $(this).prop('style');
//or:
var thisAttr = $(this).attr('style');

console.log(getAtt, thisProp, thisAttr);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<div id='id' style="color: red;background: orange;">test</div>





(см. Также эту скрипку: http://jsfiddle.net/maniator/JpUF2/)



консоль журналы getAttribute как строка, а то attr как строку, а prop как CSSStyleDeclaration, почему? И как это повлияет на мое кодирование в будущем?

549   0  

Comments

    Ничего не найдено.