Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 746225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:03:58+00:00 2026-05-14T14:03:58+00:00

I am a jQuery noobie, and have been trying to add a script to

  • 0

I am a jQuery noobie, and have been trying to add a script to change the id of a div onClick.

Here is a jsfiddle example.

$(function accept() {
    $("div:scrollwrap").attr('scrollwrap','highlight');
});​

Thanks 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:03:58+00:00Added an answer on May 14, 2026 at 2:03 pm

    The first parameter of attr should be the attribute name, not the current value:

    $(function accept() {
        $("div#scrollwrap").attr('id','highlight');
    });​
    

    However, reading your jsFiddle code, you appear to have a class of highlight and not an ID. Here is my edited version with what I think you are trying to achieve.

    Note that I have changed the following:

    • Made the .hightlight class more specific by adding the ID, otherwise the highlight style will not override the original.
    • Removed the inline onClick as you can do this within your script, which is considered best practice (see JS for the .click() addition)
    • Changed the JS function to toggle the class, as I assume it should be invalidated if the user deselects the checkbox.

    More resources (jQuery docs):

    • .toggleClass()
    • .click()
    • .attr()
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

jquery call $(form[name='searchbox-purchase'] select[name='city']).change(function(){ }); i have 4 forms with following names searchbox-purchase searchbox-rental
Hi all a bit of a noobie jquery problem with codaslider I'm afriad. I
jQuery: $(#contact-us-form).submit(function () { var nameVal = $(input[name=name]).val(); var companyVal = $(input[name=company]).val(); var titleVal
jQuery.parseJSON('{"name":"John"}') converts string representation to object but I want the reverse. Object is to
jQuery 1.4.2 omits the timestamp GET parameter (to defeat browser cacheing) if I assert
jQuery was updated over the weekend. How long should I expect to wait before
jQuery plugins use a pattern like this to hide private functions of a plugin:
jQuery trim not working. I wrote the following command to remove white space. Whats
jquery Ui AutoComplete has a property that named Source. i want to value this
jQuery plugins make code much more reusable. I previously made a plugin that would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.