Question

I am trying to use this code in my html file. It will work if I use the link http://jsfiddle.net/eqkmv/1/show/ however the javascript doesn't work when I try to View Page Source and copy/paste the code into an html file.

here is the javascript:

<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
$('#search').submit(function (e) {
e.preventDefault();

MoneyForTrip();

return false;
});

function MoneyForTrip() {
var money = parseInt(document.getElementById('moneyfortrip').value);

$('.trip-result').hide();

if (money <= 800) {
    $('.trip-less-800').show();
}

if (money > 800 && money <= 1200) {
    $('.trip-800-1200').show();
}
}
});//]]>  

</script>

Am I missing something?

Was it helpful?

Solution

Add jQuery in the <head>

<script src= "http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top