I have to use javascript code inside Razor. The code is:
@if (element.ParentItemID == null)
{
    <script type="text/javascript">
        $(window).resize(function () {
            if ($(window).width() > 640) {
                @Html.ActionLink(element.PageTitle, "Details", "Items", new { @parentitem = "website", @url = (element.Url) }, new { @class = "" })
            }
            else {
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">@element.PageTitle</a>
            }
        }); //show syntax error
    </script>
}
Without javascript code , it generates a Menu. But when I use code above it shows nothing.
I tried solution here, but its not working in this case: Mix Razor and Javascript code
 
     
    