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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:09:09+00:00 2026-06-18T07:09:09+00:00

Sorry I am just really starting to get into javascript and I can’t nail

  • 0

Sorry I am just really starting to get into javascript and I can’t nail down the syntax.

Here is my script:

jQuery(document).ready(function ($) {
    $('div[align="right"][style="margin-right:15px;"]').each(function () {
        $(this).removeAttr('align')
        $(this).removeAttr('style');
        $(this).addClass('homepagecontent2');
    });
});

Basically I just want to find every div with align="right" and style="margin-right:15px;" and then remove the align and style and add the class.

It works fine when I just look for align="right" but when I add the second element into the equation it breaks.

  • 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-18T07:09:11+00:00Added an answer on June 18, 2026 at 7:09 am

    It is better to filter elements by CSS style:

    $("div[align='right']").filter(function() {
        return $(this).css("margin-right") === "15px";
    }).removeAttr("align style").addClass("homepagecontent2");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I was just writing another basic script for my JS & jQuery practice,
I am trying to write a simple script in JavaScript, just for testing purposes.
Sorry about the title but I can't really think of a quick way of
Sorry if this sounds stupid but I'm really new to LiftWeb and just struggling
Sorry for a really lame question, just figured out that I'm not familiar with
Sorry if its just me who is scratching the head looking at this code,
sorry for the stupid questions but there are just some things about WCF I
Sorry if this is dumb but I was just thinking I should give a
Sorry. I'm just bitten (or bit. Go figure with this left-to-right language :-) I've
Sorry for my inpatience but after weeks staying up late and just having put

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.