Solved

jquery .hide

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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…
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 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…

820 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