Reputation: 5477
A quick question. Is it possible to select (html
) element in external .js
file using jquery
?
I have abc.js
file and a xyz class
. Why following code is not working?
//abc.js
$('.xyz').hide();
Upvotes: 1
Views: 200
Reputation: 1631
Yes.This is possible.your code structure would be as Following:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="js/abc.js"></script>
your abc.js
code:
$(function(){
$('.xyz').hide();
});
Upvotes: 2