Question: I'm trying to access an attribute of the head tag with a script that's placed within the head.

```
<head myattr="123">
    <script src="/Scripts/jquery.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        alert($("head").attr("myattr"));

    </script>
    ...

```

I cannot use includes or <%#"123%> or <%="123%> in .net "because of code execution order & page header dabinding. So i just set header attribute from code-behind.

Anyway the question is: is there something wrong with the way i'm approaching the problem?
Is it possible that when i call `alert($("head").attr("myattr"));` that i could get an `undefined` response?

I'm assuming that since `<head myattr="123">` happens before the `alert(...)` script is called, i won't get an `undefined` alert ... am i assuming wrong?

EDIT: Forgot to mention. Can't use `$(document).ready(...` it has to execute in the header.
I'm basically concerned if there are any unknowns such as compatibility issues etc that i'm not taking into considerations. Maybe some browsers will return undefined some not? maybe it can execute too early in some cases?

Answer: 
It's fine, since your script is after/within the head tag. However, `myattr` makes your HTML invalid.
Make your `alert()` call after the DOM is loaded, like this:

```
$(function() {
     alert(...)
});

```