$('#<%=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 ?
Asked
Active
Viewed 1,466 times
-2
-
what????????????? you just want a single statement on a new js file – Shivam Shah Aug 03 '12 at 16:04
-
No actually I moved everything and I have some asp code in btwn this javascript which i have to convert either into java script or jquery as we cannot use asp coding in external java script file – Reddy Aug 03 '12 at 16:11
-
You would probably add the server data to a data attribute of an element, and retrieve this data using javascript. – dqhendricks Aug 03 '12 at 16:17
-
What are you asking, what is this question? – Daniel Aug 06 '12 at 00:09
-
Please improve the question with more information – Tiago Sippert May 24 '13 at 13:53
2 Answers
0
Create a file called nameOfFile.js
and copy your javascript code to it, without the <script>
tags that surrounded it inline. Then load the external file into your main file using the <script>
src attribute:
<script type="text/javascript" src="pathToFile.js"></script>

Alex Kalicki
- 1,533
- 9
- 20
-
won't work, as the OP's using .NET databinding on the page within the js selector. – RYFN Aug 03 '12 at 16:10
-
Really..??I did all these I moved all the java script into external js file.. I have some asp code in btwn this javascript which i have to convert either into java script or jquery.so am facing prob with this particular line..as that is asp code i have to convert that into javascript – Reddy Aug 03 '12 at 16:14
0
You could use the jQuery ends with
selector here:
$('[id$="pnlCheckout"]')
Which will match any element for which the ID ends with pnlCheckout
Your final js would then be:
$('[id$="pnlCheckout"] div.listitem').length
related: jQuery Selector: Id Ends With?