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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:08:06+00:00 2026-06-11T00:08:06+00:00

Using LESS CSS I was able to restrict entire stylesheets to acting on a

  • 0

Using LESS CSS I was able to restrict entire stylesheets to acting on a specific div element. I would like to restrict entire javascript files to a specific div element on my page.

For example, a js file that is bootstrapped at the head of the page has code the manipulates table elements in the DOM. It does its job but also does ALL table elements on the page not the one specific one I wanted. Now the practical soultion is to change all ofthe respective jquery selectors to a more specific identifier. I know that. But there is mountains upon mountains of code and that is not feasible to do.

Is there a way to restrict javascript/jquery code to a specific div?

I want to avoid using iframes also.

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-06-11T00:08:08+00:00Added an answer on June 11, 2026 at 12:08 am

    You’re able to check for elements if (jQuery('#element').html() !== null).

    In this case i’m looking if #element is present in the dom. If it returns true i’am loading my plugin via ajax.

    if (jQuery('#element').html() !== null) {
        jQuery.ajax({
            url: '../assets/js/plugins/myplugin.js',
            type: 'GET',
            dataType: 'script',
            cache: true,
            success: function(data, textStatus, xhr) {
                // Do whatever you want
            }
        });
    }
    

    But if you have multiple similar elements you can’t be specific without to change your selector. Maybe you can deal width the index (position in DOM) of an element.

    $("div:eq(2)") //get third div
    
    • http://api.jquery.com/index/
    • http://api.jquery.com/eq-selector/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using LESS and I find it very useful I would like to
I would like to have all javascript, css and images that are sent to
I have a number of less file that I would like to compile using
What would be the best way to write this old CSS using LESS? .paginationContainerTop
I write my CSS with Lesscss using it on client side (with compiler less.js).
I have a 3 column layout using table-less design. <div id=main> <div id=left></div> <div
Wanted to try something new, using the awesome twitter bootstrap and their Less CSS
I am currently looking at changing from using css to LESS in my current
Is there a way to use JavaScript inside a LESS CSS file..? What I
I'm using LESS CSS (more exactly less.js) which seems to exploit LocalStorage under 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.