Jquery how to find an Object by attribute in an Array

前端 未结 11 2157
灰色年华
灰色年华 2020-12-02 11:55

Given I have an array of \"purpose\" objects:

//array of purpose objects:
var purposeObjects = [
    {purpose: \"daily\"},
    {purpose: \"weekly\"},
    {pu         


        
11条回答
  •  臣服心动
    2020-12-02 12:26

    If your array is actually a set of JQuery objects, what about simply using the .filter() method ?

    purposeObjects.filter('[purpose="daily"]')
    

提交回复
热议问题