Solved

jquery .hide

Posted on 2016-10-24
1
36 Views
Last Modified: 2016-10-24
in jquery this hides all the divs using this class DivStyle1 with theses ids.

$("div.DivStyle1[id*='Table1Row20']").hide();
$("div.DivStyle1[id*='Table1Row21']").hide();
$("div.DivStyle1[id*='Table1Row22']").hide();
$("div.DivStyle1[id*='Table1Row23']").hide();
$("div.DivStyle1[id*='Table1Row24']").hide();
$("div.DivStyle1[id*='Table1Row25']").hide();


Is there a shortcut way to say hide everything with id where the number it ends with is greater than or equal to 20

Basically i want a one line equality to hide the items above.

Any ideas of the syntax
0
Comment
Question by:maqskywalker
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 41857297
Take  look at this:

$('div.DivStyle1').filter(function() {
    return parseInt(this.id.replace('Table1Row','')) >= 20;
}).hide();

Open in new window

1

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question