SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using Jquery to remove attribute from all elements with same class?

    Hello, I have a few input button classes all with the same class. When a user clicks on the input button, then I disable the input button so the user does not click on it again. I want to make it so when the user goes back, all of the buttons of the same class are active again(including the one that the user just clicked on). So, on document ready, I have the following:
    Code:
          $('.compare_prices_button').removeAttr('disabled');
    It does not seem to work, though.
    How do I remove the disabled attribute from all elements with the same class?
    Thanks!

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Could you post your full javascript code including any HTML or post a link to a working demo as its hard to debug without a full source.
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2007
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SgtLegend View Post
    Could you post your full javascript code including any HTML or post a link to a working demo as its hard to debug without a full source.
    Hello,
    The working demo can be found at TextbookPop
    I have two problems:
    When doing a search in Chrome, the search pauses at the animation for an indefinite period of time.
    In a browser that works, after a keyword is entered in the main search bar, and the user clicks "Compare Prices" for one of the keywords, then presses the back button, then the button is disabled.

    If you view the page's source, all of the JQuery code is located in the footer. I am not exactly sure if I am correctly coding the AJAX get request. The AJAX get request can be found under the comment: "// Process search submit click" at the bottom of the page source.

    [QUOTE=paul_wilkins;4847714]I don't think it's possible to remove the disabled attribute, but you should be able to set it to false which should enable the field.

    That does not seem to work for me. When I make those changes, then I am unable to click the button.

    Thanks!

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,527
    Mentioned
    84 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by newblogger View Post
    So, on document ready, I have the following:
    Code:
          $('.compare_prices_button').removeAttr('disabled');
    It does not seem to work, though.
    I don't think it's possible to remove the disabled attribute, but you should be able to set it to false which should enable the field.

    Code:
    $('.compare_prices_button').attr('disabled', false);
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •