I need to get the value of the content
attribute of a certain meta
tag.
var someContent = $("meta[name=someKindOfId]").attr("content");
is how I usually do it. For business reasons, someKindOfId
may be somekindofid
. It could be other combinations of cases as well. I don't know.
What is the best way to search for this meta tag? Adding an id or other identifier is out of the question.
jQuery attribute value selectors are generally case-sensitive.
jQuery :contains() SelectorThe :contains() selector selects elements containing the specified string. The string can be contained directly in the element as text, or in a child element. This is mostly used together with another selector to select the elements containing the text in a group (like in the example above).
CSS is case insensitive. And CSS class, id , urls, font-families are case sensitive.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With