将嵌入式JavaScript移至外部文件 [英] Moved inline javascript to external file

查看:142
本文介绍了将嵌入式JavaScript移至外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$('#<%= pnlCheckout.ClientID%> div.listitem').length在我的页面级javascript中有此问题,我必须将其移至外部javascript文件中,有人可以帮助我如何做到这一点吗?

$('#<%=pnlCheckout.ClientID%> div.listitem').length am having this on my page level javascript I have to move this to external javascript file could anyone plz help me how to do this ?

推荐答案

您可以使用jQuery

You could use the jQuery ends with selector here:

$('[id$="pnlCheckout"]')

将匹配ID以pnlCheckout

您的最终js将是:

 $('[id$="pnlCheckout"] div.listitem').length

相关: jQuery选择器:ID以?结尾吗?

这篇关于将嵌入式JavaScript移至外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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