Solved

jquery .hide

Posted on 2016-10-24
1
28 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
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

914 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now