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

  • SEARCH
  • Home
  • 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

Hi guys I'm a jquery noobie, just started jqueryUI Problem OverView: I'm trying to
Jquery: <script type=text/javascript src=http://code.jquery.com/jquery-1.7.2.min.js></script> <script type=text/javascript src=js/timeago.js ></script> $(document).ready(function(){ jQuery(abbr.timeago).timeago(); }); html: <abbr class=timeago
jQuery(document).ready(function(){ var panelContainer = jQuery('div#panels'); jQuery('<div id=tabs></div>').insertBefore(panelContainer); panelContainer.find('div.panel').each(function(n){ jQuery('div#tabs').append('<a class=tab href=#' + (n+1) +
jQuery's deferred's have never liked me, and I've never been fully able to understand
jQuery 1.7.1, jQuery UI tabs. I have the following HTML representing tabs, <div id=tabs>
JQUERY <script type=text/javascript src=jquery-1.5.1.min.js></script> <script type=text/javascript> $('#aggiungi').live('click', function(){ var thisRow = $(this).parent().parent(); // clone
jQuery(function ($) { $('input.adud').on('click', function() { var thisdiv = $(this).parents('div').attr(id); var thisform = $(this).parents('form').attr(id);
sort of a jQuery noobie here.. I am wondering if there is a way
Somewhat new to JS/jQuery, but I am trying to change the value of a
Jquery did not carry out!!!I don't know why $(.other-edithion).click(function(){ var city = $(this).closest('#city'); if

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.