Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. $("#product1 :checkbox").click(function(){
  2. $(this)
  3. .closest('tr') // Find the parent row.
  4. .find(":input[type='text']") // Find text elements in that row.
  5. .attr('disabled',false).toggleClass('disabled') // Enable them.
  6. .end() // Go back to the row.
  7. .siblings() // Get its siblings
  8. .find(":input[type='text']") // Find text elements in those rows.
  9. .attr('disabled',true).removeClass('disabled'); // Disable them.
  10. });
  11.  
  12. $(el).prop("disabled",!$(el).prop("disabled"))
  13.  
  14. $(el).prop('disabled', function() { return !$(this).prop('disabled') })
  15.  
  16. (function($) {
  17. $.fn.toggleDisabled = function() {
  18. return this.each(function() {
  19. var $this = $(this);
  20. if ($this.attr('disabled')) $this.removeAttr('disabled');
  21. else $this.attr('disabled', 'disabled');
  22. });
  23. };
  24. })(jQuery);
  25.  
  26. (function($) {
  27. $.fn.toggleDisabled = function(){
  28. return this.each(function(){
  29. this.disabled = !this.disabled;
  30. });
  31. };
  32. })(jQuery);
  33.  
  34. attr
  35.  
  36. $("#product1 :checkbox").click(function(){
  37. $(this)
  38. .closest('tr') // find the parent row
  39. .find(":input[type='text']") // find text elements in that row
  40. .attr('disabled',function(idx, oldAttr) {
  41. return !oldAttr; // invert disabled value
  42. })
  43. .toggleClass('disabled') // enable them
  44. .end() // go back to the row
  45. .siblings() // get its siblings
  46. .find(":input[type='text']") // find text elements in those rows
  47. .attr('disabled',function(idx, oldAttr) {
  48. return !oldAttr; // invert disabled value
  49. })
  50. .removeClass('disabled'); // disable them
  51. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement