Is there a wildcard selector for identifiers (id)?

前端 未结 9 1668
臣服心动
臣服心动 2020-12-04 14:59

If I have an unknown amount of identifiers sharing a specific naming-scheme, is there a way to grab them all at once using jQuery?

// These are the IDs I\'d          


        
9条回答
  •  我在风中等你
    2020-12-04 15:44

    If you really want to match classes, not ids, the syntax is a bit more involved, since class can have multiple values.

    // handle elements like 
    $('[class^="someclass"]').click(function() { // do stuff }); // handle elements like
    $('[class*=" someclass"]').click(function() { // do stuff });

提交回复
热议问题