简体   繁体   中英

How to pass variable defined in scripts to division tag in ASP.NET MVC5 razor view?

I just want to pass value of target from script to division tag in mvc. Here are the codes I have done.

Scripts:

@section Scripts{
    <script type="text/javascript">
            $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
                var target = $(e.target).attr("link") // activated tab
                alert(target);
            });
    </script>
}

DIV:(outer division)

<div class="ibox-title">
                    <h5><i class="fa fa-newspaper-o"></i> &nbsp; News &amp; Events</h5>
                    <div class="ibox-tools">
                        <a href="@Url.Action("List","News")" style="color: #00a650;font-weight:600;">View All</a>
                    </div>
                </div>

I just want value of target to display inside this division.

Where: News in @URl.Action("List","News") should be replaced by target's value.

Give the div an id then use jQuery.append to add the html:

<div id="Target">
..
..
<b> target </b>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM