I want to make a generic function in jquery for select all functionality. I have a tabbed view in my web page.
Id of my component is : tabId:someDynamicId:rowId:componentId
where, someDynamicId is dynamically generated.
So in jquery i want to find the element whose id starts with – tabId:someDynamicId & ends with componentId. And, tabId, someDynamicId & componentId would be passed as an argument to the generic function where this element needs to be find.
It’s simple:
Wildcards in jQuery selectors
But i’m recommending to use right tools for this job. ID’s are useful for finding specific element, but in your case it’s better to use one or two classes and data attributes. For example:
Then find all $(‘.tabs’) elements and use $(this).data(‘component-id’) and $(this).data(‘tab-id’)
Update:
There is example of using this as function: