Case-insensitive attribute-value selector with Jquery

后端 未结 3 1904
名媛妹妹
名媛妹妹 2020-12-01 18:49

I need to get the value of the content attribute of a certain meta tag.

var someContent = $(\"meta[name=someKindOfId]\").attr(\"con         


        
3条回答
  •  生来不讨喜
    2020-12-01 19:20

    You could use the jquery filter function like so

    var meta = $('meta[name]').filter(function() {
        return this.name.toLowerCase() == 'somekindofid';
    });
    

    Based upon CSS selector case insensitive for attributes

    http://jsfiddle.net/nickywaites/mkBvC/

提交回复
热议问题