-2

$('#<%=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 ?

Reddy
  • 11
  • 5

2 Answers2

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?

Community
  • 1
  • 1
RYFN
  • 2,939
  • 1
  • 29
  • 40