Assign href via jquery

0

I have an element in my Layout and I'm trying to set the href via jquery, but it will not. The code is in my index. Here is the code:

Layout

<div class="three wide column dindex">
        <div class="ui left fixed vertical blue inverted menu dmenu">
            <div class="ui containe">
                <h3 class="item">Menu Principal</h3>
            </div>
            <div class="ui container firstmenu">
                <a id="itemsMD" class="item dalink menus" href="~/EAD/EDisciplinas/Conteudo">Material Didático</a>
                <!--<a id="items" class="item" title="curso" href="#curso">Notas</a>-->
                <a id="itemsA" class="item dalink menus">Avisos</a>
            </div>
            <div class="ui container secondmenu">
                <a id="itemsP" class="item dalink" href="~/EAD/EPrincipal">Disciplinas</a>
                <a id="itemsS" class="item dalink" href="~/EAD/EAccount/Sair">Sair</a>
            </div>
        </div>
    </div>

Index - Jquery Code

<script type="text/javascript">
$(function()
{
    /* Atribui ID */
    $("#itemsA").attr("href", "@ViewBag.IDDisciplina");
    /* CRIA A HREF */
    $('<a>', {
        class: 'item dalink',
        href: '~/EAD/EDisciplinas/Forum/@ViewBag.IDDisciplina',
        text: 'Forum de Discussão'
    }).appendTo('.firstmenu');
});

It creates the href but looks like this: p>

But I wish it were only link

Can anyone help me? I'm programming in C # asp.net MVC 5

    
asked by anonymous 03.06.2016 / 19:15

1 answer

1

Hello,

Put it like this.

$(function()
{
    /* Atribui ID */
    $("#itemsA").attr("href", "@ViewBag.IDDisciplina");
    /* CRIA A HREF */
    $('<a>', {
        class: 'item dalink',
        href: '/EAD/EDisciplinas/Forum/@ViewBag.IDDisciplina',
        text: 'Forum de Discussão'
    }).appendTo('.firstmenu');
});
    
03.06.2016 / 19:33