0

I want to make this source code, I copy this source code in my notepad and I paste it in one file, include CSS, JavaScript and HTML. The file name is sel.php.

I take the source code from http://jsfiddle.net/davidThomas/x5YW3/

I include my CSS with:

<style type="text/css">
----this_source_css----
</style>

JavaScript with :

<script type="text/javascript">
----this_source_javascript----
</script>

And HTML in:

<html>
<body>
----html_source_code----
</body>
</html>

But this code does not work in my copy paste, whereas I run in jsfiddle working fine, what might be wrong?

Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
pwcahyo
  • 67
  • 1
  • 10
  • You need a `head` element and put the CSS and Javascript in there. See eg. http://dev.opera.com/articles/view/13-the-html-head-element/ (doesn't matter that it's marked deprecated) – Pekka Jan 06 '13 at 12:40
  • Are you also including the jQuery library used in the linked jfiddle? – Boaz Jan 06 '13 at 12:41
  • @Pekka i use `` and doesn't work. @Boaz jquery ? jquery from where ? in jsfiddle, i'm not see jquery source code. – pwcahyo Jan 06 '13 at 12:47
  • @insomniart show your full HTML – Pekka Jan 06 '13 at 12:48
  • @Pekka i'm sory i paste in field html http://jsfiddle.net/insomniart/yyaV5/ and thanks for your response, – pwcahyo Jan 06 '13 at 13:04
  • The JSFiddle is not helpful here, as it will serve a document that already has a head section and other parts of the body. You'll need to show us the naked HTML that isn't working – Pekka Jan 06 '13 at 13:09

2 Answers2

1

Just a guess - include your javascript-

$(document).ready(function(){
// your code here
});

Also make sure you included JQuery source in your file.

However, Your fiddle code is being executed "onLoad" - check the dropbox below "Choose Framework".

As Pekka pointed out, if you do intend your code to run after "load" instead when your dom is ready, you can use this -

$(document).load(function() {
// your code here
});

An explanation of the difference between the two events is here

Community
  • 1
  • 1
Johnbabu Koppolu
  • 3,212
  • 2
  • 22
  • 34
1

As @Boaz Said:

You haven't included jQuery in your document. Get the latest version from jquery.com and also use this:

$( function() {

// paste js code here

});
Muhammad Talha Akbar
  • 9,952
  • 6
  • 38
  • 62