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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:41:43+00:00 2026-06-12T18:41:43+00:00

I have the feeling I’m doing dirty code, although it works fine… How could

  • 0

I have the feeling I’m doing dirty code, although it works fine…

How could I replace those IF statement by regular JQuery selectors in such case:

see code + fiddler

<html>
<body>
    <a href="#b" class="cssPauseAll" historyID="12">Pause All</a><br/>

        <a href="#b" itemHistoryID="12" ContentID="45">AA</a><br/>
        <a href="#b" itemHistoryID="12" ContentID="14">BB</a><br/>
        <a href="#b" itemHistoryID="12" ContentID="78">AA</a><br/>  

    <a href="#b" class="cssPauseAll" historyID="13">Pause All</a><br/>

        <a href="#b" itemHistoryID="13" ContentID="45">BB</a><br/>
        <a href="#b" itemHistoryID="13" ContentID="14">BB</a><br/>
        <a href="#b" itemHistoryID="13" ContentID="78">CC</a><br/> 
</body>    
</html>​

$(document).ready(function () {

    $(document).on("click","a.cssPauseAll[historyID]", function () {
        var historyID = $(this).attr("historyID");
        //alert("historyID from PauseAll  " + $(this).attr("historyID"));
        $(document).find("[itemHistoryID]").each(function() {

            var itemHistoryID = $(this).attr("itemHistoryID");

            if(historyID == itemHistoryID)
            {
                alert($(this).attr("ContentID"));
            }
        });

    });

});​

Fiddler

  • 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-12T18:41:44+00:00Added an answer on June 12, 2026 at 6:41 pm

    You can concatenate the strings:

    $("a[itemHistoryID='" + historyID + "']");
    

    http://jsfiddle.net/FBCBP/

    Please note that there is no need to select the document object and use the find method. You can select the element using $ or jQuery directly and also using attribute selector alone is very slow, you can use element selector before attribute selector(in this casea).

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

Sidebar

Related Questions

I have a feeling that this is a code smell, and I could be
I have a feeling I am doing something wrong, but this behavior seems odd.
I have a feeling I'm doing something wrong here, but I'm not quite sure
I have a feeling this is going to be one of those bone-headed questions.
I have a feeling I'm doing this horribly, horribly wrong. Nested for loops? What
I have the feeling that using joins could make this cleaner public override string[]
I have a feeling I'm going about this all wrong. But anyway. I have
I have a feeling I'm asking a stupid question here. I'm having trouble retrieving
I have a feeling this XML is not valid, can someone please explain why?
I have a feeling I already know the answer people are going to give,

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.