You can use the startswith CSS3 selector to get those divs:
$('div[class^="project"]')
To check one particular element, you’d use .is()
, not hasClass
:
$el.is('[class^="project"]')
For using the exact /project\d/
regex, you can check out jQuery selector regular expressions or use
/(^|\s)project\d(\s|$)/.test($el.attr("class"))
Related Contents:
- jQuery: Finding partial class name [duplicate]
- jQuery – get the first class only from a element
- jQuery AJAX file upload PHP
- jQuery: Return data after ajax call success [duplicate]
- Ajax request returns 200 OK, but an error event is fired instead of success
- Export html table data to Excel using JavaScript / JQuery is not working properly in chrome browser
- Detecting when a div’s height changes using jQuery
- jQuery has deprecated synchronous XMLHTTPRequest
- How to expose IFrame’s DOM using jQuery?
- Prevent RequireJS from Caching Required Scripts
- jQuery selectors on custom data attributes using HTML5
- HTML5 Canvas toDataURL returns blank
- jQuery : simulating a click on a doesn’t work in Firefox? [duplicate]
- What’s the best way to retry an AJAX request on failure using jQuery?
- Clear Text Selection with JavaScript
- How to upload a file using jQuery.ajax and FormData
- Display A Popup Only Once Per User
- Find out how long an Ajax request took to complete
- How do I detect “shift+enter” and generate a new line in Textarea?
- Sort an array by the “Levenshtein Distance” with best performance in Javascript
- What’s the purpose of starting semi colon at beginning of JavaScript? [duplicate]
- Detect if an element is visible with jQuery [duplicate]
- One time page refresh after first page load
- How to add a “readonly” attribute to an ?
- Convert simple array into two-dimensional array (matrix)
- Twitter Bootstrap alert message close and open again
- jQuery: exclude children from .text() [duplicate]
- React functional components vs classical components
- Limiting the number of characters in a ContentEditable div
- Is it possible to append a div inside an SVG element?
- jQuery issue in Internet Explorer 8
- console.log(result) prints [object Object]. How do I get result.name? [duplicate]
- Find and replace specific text characters across a document with JS
- What is the elegant way to get the latest date from array of objects in client side?
- jQuery get the location of an element relative to window
- CSS3-Animate elements if visible in viewport (Page Scroll)
- Smooth scroll to specific div on click
- How can I get jQuery .val() AFTER keypress event?
- JavaScript: get code to run every minute
- Remove plus sign (+) in URL query string
- Change Height based on Browser Size/Resize
- Create array of all integers between two numbers, inclusive, in Javascript/jQuery
- how to break the _.each function in underscore.js
- Get the offset position of the caret in a textarea in pixels [duplicate]
- Get translate3d values of a div?
- Running Javascript in new window.open
- Cropping with drawImage not working in Safari
- Javascript function to Rotate a base 64 image by X degrees and return new base64
- Event propagation in Javascript
- jQuery in Chrome returns “block” instead of “inline”