Can you just specify a new class when you create those thumbnails, and style accordingly?
If this is what you want to do:
You need to grab every element that has the [data-id] attribute into an object array
var ids = document.querySelectorAll("[data-id]");
Then you need to iterate over them, and check the value:
ids.forEach((el) => {
if (parseInt(el.dataset.id) > 100) {
el.classList.add("new-style");
}
});
You can add the new styling in your CSS (so you can change it as needed without touching the js)
You want to wrap the js in a document ready so the elements are there before it starts, or it’ll return undefined.
The final code:
document.addEventListener("DOMContentLoaded", function () {
var ids = document.querySelectorAll("[data-id]");
ids.forEach((el) => {
if (parseInt(el.dataset.id) > 100) {
el.classList.add("new-product");
}
});
});
Then you can target the new products using .new-product{} in your CSS files.
I hope that helps!
Related Posts:
- Hide Add to Cart Button
- Woocommerce checkout fields on the same line
- WooCommerce: The model of e-mail is displaying only the html, not css [closed]
- Update html tag class values based on Woocommerce product attribute dropdown selection [closed]
- WooCommerce Country Drop Down colours CSS [closed]
- show content of a page built using yootheme builder on different page/template
- WordPress Twenty Seventeen header image size not responsive for mobile
- Checkout form looks terrible [closed]
- how customise Woocommerce style of custom theme
- Trying to style Woocommerce sidebar Cart Widget [closed]
- How to Remove Active css from woocommerce variation?
- Online wc-blocks-style.css rendering instead of the hosted wc-blocks-style.css
- Can’t hide product attributes with css on WooCommerce Product Page
- How to hide “Shipping” label from Woocommerce cart page
- How can I make a thumbnail slider
- How to hide a random text with a div tag using a class on product pages with a specific tag
- Two Filter Issue [closed]
- How to edit wc_get_template_part for archive products
- How to make wocommerce shop products same heigt
- Woocommerce doesn’t work with theme, header missing and css messed up
- How to display 2 products per row for Mobile using WooCommerce?
- How do I make my products on the homepage responsive?
- Photo cover in WooCommerce
- Pseudo class :before don’t working in a specific button
- WooCommerce Storefront site-header padding
- Website Tablet Check Out Field Issue
- Trying to link to a custom css file in a new folder
- How do I make a diagonal strikethrough on wordpress? [closed]
- How to add my theme’s style to woocommerce blocks?
- CSS url rules not relative to css path in account endpoint areas. IE. subscriptions
- WooCommerce: I Need to hide my page title/header (including menu) from all the WooCommerce related product pages, such as category and keyword pages
- Woocommerce product not responsive
- Woocommerce – Add a product to cart programmatically via JS or PHP [closed]
- ( Woocommerce) How to get the user belonging to an order? [closed]
- Product categories don’t appear as option to build menu
- Woocommerce show cross sells on singe product page [closed]
- WooCommerce: Webhook disabled on its own
- Insert variations via woocommerce api [closed]
- How to delete woo commerce order pragmatically? [closed]
- How to turn off WooCommerce user registration and manually create accounts?
- Hook and send Woocommerce data after click Place Order button
- WooCommerce Change Product Global Attribute Value via CRUD for Simple Product [closed]
- When Free shipping is available hide other shipping methods except Local pickup in WooCommerce [closed]
- Change WooCommerce Image Size in One Product CAtegory
- Is there a way to get customers logged out without calling wp-login.php?
- WooCommerce lost password reset flow not working with SendGrid (redirect loop)
- Change add to cart text if a product is in cart on WooCommerce
- Get user payment details when payment successfully done in woocommerce [closed]
- How to assign specific attribute to variation for woocommerce product?
- How to change page via login as user and admin
- WooCommerce checkout: How can I change $field_container of a checkout field?
- How to remove the sub-category from Woocommerce product URL
- Find woocommerce product ID by custom field value?
- Woocommerce Shop Price Position
- How to disable users from editing billing address in WooCommerce checkout?
- Move WooCommerce product tabs out of the tabs [closed]
- Is it possible to recalculate cart prices? [closed]
- Getting WordPress database error Deadlock
- WooCommerce WebHook Retry
- Can I set a custom “alt” attribute with woocommerce_get_product_thumbnail()?
- Remove all Span Tags and class From Woocommerce Price [closed]
- Importing Woocommerce products with variations
- Woocommerce login not working on the first try
- Show add to cart button on shop woocommerce
- How do I hide the purchase note in the WooCommerce ‘order completed’ email?
- Woocommerce – Override the default templates location under the theme directory
- How to hide out of stock products in Related Products via custom query in WooCommerce
- Changing Woocommerce language without changing the language in Dashboard admin WordPress
- Fatal error: Call to undefined method WooCommerce::nonce_field()
- Where do I find where woocommerce stores product data in cpanel file manager?
- Woocommerce wp-admin search products through custom meta value too
- Place Order button in Checkout
- WOO-Commerce translation | Tried it all [closed]
- woocommerce – How Can I add author metadata for a product? [closed]
- Is there a way to show Single Variation prices in the product loop when filters or attributes are active?
- Function to recalculate shipping costs on subscriptions after renewal with Automatewoo
- Creating a multisite registration form that also creates a woocommerce post
- Server-Based CRON Job
- Woocommerce – Want to move the product tabs below short description
- Where is the CSS class ui-sortable-handle for WC_Admin_Taxonomies added?
- WooCommerce: “account is already registered with your email address”
- Enter name and email on the Product page and keep the input data on the Checkout page
- Separeting product from post in search result
- Woocommerce: Same gross price for different tax rates [closed]
- add shoppy.gg to woocommerce instead of add to card [closed]
- List of shipping on product page [closed]
- How to show tag count for individual product post in wordpress woocommerce
- Checkout is blocked with blockUI when using action woocommerce_cart_calculate_fees
- Woo commerce using add_fee to add discount to cart not saving discount amount the admin backend when guest user is shopping
- How to change Attribute Type
- WooCommerce plugin won’t let me access settings
- How to edit T&C checker text in Woocommerce checkout page? gettext?
- What is the reason for two classes storefront_woocommerce and storefront
- Get email type inside email template – order emails
- Caption not showing with Woo commerce thumbnails
- Change the Title Tag of Search Products Page
- API returns blank response after installing & uninstalling WP-rest-api plugin
- Tried to create a user role that can only edit user information, but my test account cannot view the dashboard. What am I missing?
- Filtering variable WooCommerce products by stock level using meta_query
- How can I run a multi language WordPress site in two folders in one install? [closed]