Saqib Omer
Saqib Omer

Reputation: 5477

select html element in external jquery file

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

Answers (1)

Mr7-itsurdeveloper
Mr7-itsurdeveloper

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

Related Questions