MJ
asked on
Detect If Div Class name starts with "modal" and has specific ID or just look for specific ID?
How would I check in JavaScript (jQuery ok but not preferred) if a div class starts with the word "modal" and has a specific ID? So for the below example, I'd want to check if div started with "modal" and has an ID of "existingAppModalBox". I will have a list of IDs I need to check against but this will always be against a div with a class starting with the word "modal"? Or would it be easier to just check for the specific ID? My challenge is that these are modals so they have to be visible, thoughts?
Thanks!
<div class="modal in confirmationModal" tabindex="-1" role="dialog" id="existingAppModalBox" data-hard-modal="True" style="display: none;" aria-hidden="true">
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both! Much appreciated!
Open in new window
You can see it in action at: http://jsfiddle.net/bspxcePS: I changed your Div tag a bit to test the scenario, I hope you got the idea how it can be done. I am not checking for modal in this snippet, let me know if it is a must have. If you just need to check against couple of classes, add them to the ListOfIDs array and you are good to go.