Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Attribute vs property var originalHref = $('a#logo').attr('href'); // "/home" var isChecked = $('#agree').prop('checked'); // true/false // Set an attribute $('img').attr('src', '/images/new-photo.jpg'); // Enable / disable a button $('#submit').prop('disabled', true); $('#submit').prop('disabled', false); // Remove an attribute $('input').removeAttr('readonly'); // Read a data-* attribute var userId = $('#profile').data('user-id'); console.log('User ID:', userId);
Result
Open