get regex classnames using javascript

Thanks to my friend priya for saving my time with simple solution.

Example:

giftcard1 (1)

 

To get all classnames that starts with giftcard , you can achieve by

document.querySelectorAll('[class^="giftcard"]').

 

Say , your DOM has like

 giftcard2 (1)

 

Then you achieve by following

document.querySelectorAll('[class*="giftcard"] )

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s