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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:47:40+00:00 2026-05-20T09:47:40+00:00

How can i loop through all label elements in a div using jQuery or

  • 0

How can i loop through all label elements in a div using jQuery or just a JavaScript DOM

Here is the example html:

<div id="pagination">
    <label class="noLink">First</label>
    <label class="noLink">Previous</label>
    <label class="withLink" onClick="paginateTo('next')">Next</label>
    <label class="withLink" onClick="paginateTo('last')">Last</label>
</div>

What I’m trying to do here is to remove the onClick event and change class with value of withLink to noLink. I’m trying to loop all that label using JavaScript DOM and also with jQuery but still no luck. I know there is a similar question with this but can’t find one that suits my needs. Please help me with this. 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-20T09:47:41+00:00Added an answer on May 20, 2026 at 9:47 am

    Very trivial with jQuery. Looks like:

    $('#pagination .withLink').toggleClass('withLink noLink').removeAttr('onclick');
    

    Reference: .toggleClass(), removeAttr()


    Slighty trivial with vanilla Javascript:

    var lnks = document.getElementById('pagination').querySelectorAll('.withLink');
    for(var i = 0, len = lnks.length; i < len; i++) {
        lnks[i].removeAttribute('onClick');
        lnks[i].className = lnks[i].className.split(/\s/).filter(function(elem) {
            return elem !== 'withLink';
        }).join(' ');
    }
    

    Reference: .querySelectorAll(), .filter()

    Be aware that the vanilla Javascript still has Browser restrictions. It requires Javascript 1.6 so you would need IE8+ for instance.

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

Sidebar

Related Questions

I need to loop through all checkboxes that are inside a div tag with
I wrote a code in C++ CLI which can loop through all files in
How can I loop through all combinations of n playing cards in a standard
Can you cast a List<int> to List<string> somehow? I know I could loop through
How can I build a loop in JavaScript?
How can I iterate over each file in a directory using a for loop?
I need to loop through all controls on ASP.NET webpage. In configuration file I
I'm translating my VB.Net application, and I need to loop through all the controls
I am attempting to loop through all of a maps annotations and check to
I'm trying to loop through all event subscriptions for an object that : INotifyPropertyChanged

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.