删除脚本或Div [英] removing Script or Div

查看:91
本文介绍了删除脚本或Div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在存储令牌,并将其作为

I'm storing token and passing it to angular from index.cshtml as

<app data-serverData='@ViewData["token"]'>Loading..</app>

<app data-serverData='@ViewData["token"]'>Loading..</app>

一切正常,但在Webtools中

very thing working fine but in webtools

它看起来非常清晰.所以我想通过编写脚本来删除它

It appears very clearly.So I want to remove that by writing in a script

<script id=tempScript>
token = @ViewData["token"]
</script>

<div id=tempClass>
<input type="hidden" token="@ViewData["token"]">
</div>

现在,在收集令牌后的任何角度组件中,我都想删除脚本或Div,例如在Jquery $(#tempScript).remove();中,或者对于Div相同.如何在打字稿中解决这个问题.

Now,In any angular component after collecting the token I want to remove the script or Div like in Jquery $(#tempScript).remove(); or same for Div. How can I approach this in typescript.

推荐答案

您仍然可以在Angular中使用jQuery. 只需在index.html(或_Layout.cshtml,如果使用ASP.NET MVC)中的任意位置插入指向jquery.js脚本的脚本标记链接,则可以在关闭

You can still use jQuery in Angular. Just insert script tag links to jquery.js script anywhere in your index.html (or _Layout.cshtml if you used ASP.NET MVC) It's good to put before closing

<script src="./path/to/your/jquery.min.js"></script>

然后您可以在任何组件中使用jQuery,只需在声明@Component之前放置此行即可.

Then you can use jQuery in any component, just put this line before declare @Component.

declare var jQuery: any;

然后您可以通过以下方式将其删除

Then you can remove it by

jQuery('#tempscript').remove();

这篇关于删除脚本或Div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆