0

Error in Jquery

In view file (index.php)

 <script type="text/javascript" src="crosscut.js" ></script> <script src="jquery-ui.min.js" type="text/javascript"></script> <script type="text/javascript" src="mod-min.js" ></script> <script type="text/javascript" src="jquery-min.js" ></script> 

In Javascript file

$(document).ready(function() { $('#crossline').css('background-color','blue'); }); button = function() { // other code } 

I have included jquery-min.js in script and it is loaded on page loading. jquery-min.js all code loaded while inspecting through firebug .

If file may be corrupted ,So I tried live path of "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" still not works.

If calling javascript function uses jquery works fine if ready function not set .

5
  • Are there any other jQuery files loaded??? There might be a conflict Commented Dec 4, 2011 at 4:54
  • 3
    are you sure you are including the jquery lib *before the above code ? Commented Dec 4, 2011 at 4:55
  • jQuery UI is also included; var jq = $.noConflict(); jq(document).ready(function() { jq('#crossline').css('background-color','blue'); }); $ is not defined error Commented Dec 4, 2011 at 4:58
  • Just paste your code into the question. You haven't provided anything that could help anyone determine what's wrong. Commented Dec 4, 2011 at 5:00
  • @jim : I have included all lib in view file in script tags Commented Dec 4, 2011 at 5:01

2 Answers 2

13

You're not providing much info, but one issue you have is that you're loading jQueryUI before you load jQuery.

Any other files that rely on jQuery must be loaded after jQuery as well.

 <!-- this one first! --> <script type="text/javascript" src="jquery-min.js" ></script> <script type="text/javascript" src="crosscut.js" ></script> <script src="jquery-ui.min.js" type="text/javascript"></script> <script type="text/javascript" src="mod-min.js" ></script> 
Sign up to request clarification or add additional context in comments.

1 Comment

Good things seem to always come from you +1 :)
-1

if you are using jQuery.js load jQuery.js first and then other js Sequence also important.

 <script src="js/jQuery.js" type="text/javascript"></script> <script src="js/jQuery.alert.js" type="text/javascript"></script> <script src="js/jquery-1.9.1.min.js"></script> <script type="text/javascript" src="js/CustomerSummary.js"></script> <link rel="stylesheet" href="css/style.css" type="text/css"></link> <link rel="stylesheet" href="css/style_new.css" type="text/css"></link> 

2 Comments

Thanks for your answer @swati. I understand what you have trying to say, but it is already given in other answer and accepted. It is not appreciable to duplicate answer. One question, Why you are including two jQuery versions js/jQuery.js and js/jquery-1.9.1.min.js in sample code? It is not recommended to have two jQuery versions in one page.
@justin i required JQuery.js for different functionality and it work fine for me. thanks for your comment.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.