Toggle input disabled attribute using jQuery

Here is my code: $(“#product1 :checkbox”).click(function(){ $(this) .closest(‘tr’) // Find the parent row. .find(“:input[type=”text”]”) // Find text elements in that row. .attr(‘disabled’,false).toggleClass(‘disabled’) // Enable them. .end() // Go back to the row. .siblings() // Get its siblings .find(“:input[type=”text”]”) // Find text elements in those rows. .attr(‘disabled’,true).removeClass(‘disabled’); // Disable them. }); How do I toggle .attr(‘disabled’,false);? … Read more

Set attribute without value

How do I set a data attribute without adding a value in jQuery? I want this: <body data-body> I tried: $(‘body’).attr(‘data-body’); // this is a getter, not working $(‘body’).attr(‘data-body’, null); // not adding anything Everything else seems to add the second arguments as a string. Is it possible to just set an attribute without value? … Read more

.prop() vs .attr()

So jQuery 1.6 has the new function prop(). $(selector).click(function(){ //instead of: this.getAttribute(‘style’); //do i use: $(this).prop(‘style’); //or: $(this).attr(‘style’); }) or in this case do they do the same thing? And if I do have to switch to using prop(), all the old attr() calls will break if i switch to 1.6? UPDATE selector=”#id” $(selector).click(function() { … Read more