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 7781621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:17:11+00:00 2026-06-01T19:17:11+00:00

var selector = $(this); What is the proper code to change the custom attribute

  • 0
var selector = $(this);

What is the proper code to change the custom attribute data-change-me for selector?

The syntax

selector[data-change-me='someValue'];

Is not working for me

  • 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-06-01T19:17:14+00:00Added an answer on June 1, 2026 at 7:17 pm

    I think you want the attr method.

    selector.attr("data-change-me","someValue");
    

    Here’s the documentation: http://api.jquery.com/attr/

    It’s worth pointing out also that it looked like what you were trying to do was treat the jQuery wrapped DOM object as a Javascript object e.g:

    Look at the following example for what I mean:

    var myObject = {
         "data-change-me":"someValue";
    };
    
    myObject["data-change-me"] = "someOtherValue";
    

    This is valid syntax for pure Javascript objects but not jQuery. To learn about Javascript I recommend Javascript the good parts

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use this selector it its not working for me var pr
if i have this code in jquery: var parentDiv = $(this).parent('.copyInstance'); inside this div
For example, I've got a selector here var $myNeeds = $('.history'); This selector would
Here is my snippet of code: $('.content .form-submit').each(function(index) { var id = $(this).attr('id'); var
Is there a difference between the following selectors: var index = $(this).parent().index(); var index2
var _thumb = $('.galleria img[@rel='+_src+']'); Full source here Is it a deprecated selector?
var UI$Contract$ddlForm_change = function() { //'this' is currently the drop down that fires the
$('#list li a').on('click', function(e) { var user_id = this.parentNode.id.replace('list_', ''); var id = 'id='
If you run this code and click on some of the links you'll get
In this code I need to get the DOM object that is .tabs the

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.