Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

jquery .hide

Posted on 2016-10-24
1
Medium Priority
?
44 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 44

Accepted Solution

by:
Chris Stanyon earned 2000 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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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)
Suggested Courses

916 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