Solved

jquery .hide

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
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…
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)
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…

706 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

16 Experts available now in Live!

Get 1:1 Help Now