9463

by rwaldron

JavaScript

console.log( $.fn.jquery);
console.log( "textarea", $("<textarea>").attr("type")); 
// textarea does not have a "type" attr

console.log( "textarea", $("<textarea>").prop("type"));
// HTMLTextareaElement DOES have a type property
//http://www.w3.org/TR/html-markup/textarea.html


console.log( "select", $("<select>").attr("type")); 
// select does not have a "type" attr

console.log( "select", $("<select>").prop("type"));
// HTMLSelectElement DOES have a type property
//http://www.w3.org/TR/html-markup/select.html

// The exception:
console.log( "input", $("<input>").attr("type")); 
// If not type is set, then input does have a "type" attr

console.log( "input", $("<input>").prop("type")); 
// BUT it will have a type property, because the "type" 
// property is defined in the HTMLInputElement prototype

//http://www.w3.org/TR/html-markup/input.text.html#input.text