I would like to get meta content where pageDetails is my HTML page.
$(pageDetails).find('meta[name="biz-id"]').attr("content")
My HTML code is:
<meta name="biz-id" content="q6aDxTSK7njG7qWB1tSV5g">
Why is my return value always empty?
Have you tried
var bizId = $("meta[name='biz-id']").attr("content");
Also, in your request $(pageDetails).find('meta[name="biz-id"]').attr("content")it is not clear if you have pageDetailsone defined earlier. Although this has already been seen in another answer, and the question seems to have been resolved simply by mentioning it here because I was informed that I did not give this information in the comments below this answer, but as a comment below the OP.
pageDetails
Works for me here . Be careful, wait until the DOM is ready. Using jQuery:
$(function() { /* ...code here.... */ });
pageDetails. . , / , :
var $pageDetails = $('head');
, .
: $ pageDetails , , jQuery. , .
$
It looks like your quotes are back. This small example sets a business variable with what you have in the content.
var biz = $("meta[name='biz-id']").attr("content");