I have a c# web user control with an asp drop down list. I want to use jquery or similar to set the selected value based on the url of the website.

```
<asp:DropDownList ID="LangSelect" runat="server" AutoPostBack="True" OnSelectedIndexChanged="LangSelect_SelectedIndexChanged" >
    <asp:ListItem Text="English" Value="English"> English</asp:ListItem>
    <asp:ListItem Text="Français" Value="Français"></asp:ListItem>
    <asp:ListItem Text="Español" Value="Español"></asp:ListItem>
    <asp:ListItem Text="Deutsch" Value="Deutsch"></asp:ListItem>
</asp:DropDownList>

```

I have tried this:

```
<script>
    if (window.location.href.indexOf('de') > 0) {
        $("#LangSelect").val('Deutsch');
    }
</script>

```

However, its giving an error:

Uncaught TypeError: Cannot read property 'val' of null