Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

TypeError: 'undefined' is not a function (evaluating

Hi I'm getting an error, but it is not affecting the result of the code.

TypeError: 'undefined' is not a function (evaluating '( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) .apply( matched.elem, args )')

what is wrong with my code?

$(document).ready(function(){
    $(".quoteform").on("click","button", function(){
        var $price = $("#terminate").on("change","option").val();
        var $area = $("#area").val();
        var $total = $area * $price;    
        if($price == 0){
           alert("please choose a pest");
        }else{
            $("#quote").attr("value",$total);
        }
    });
});

1 Answer

If you are using Wordpress, use jQuery as the variable name, not $. JQuery(document).ready(function(){ instead of $(document).ready(function(){ here is some info on that if you are curious: http://api.jquery.com/jQuery.noConflict/

no i'm not using it on wordpress.

  <html>
<head>
<link rel="stylesheet" type="text/style" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/style" href="css/style.css">
<head>
<body>
    <div class="container" id="quoteform">
        <p>Type in the requested values</p>

        <div class="row quoteform">
            <div class="col-xs-12">
                <select id="terminate" class="form-control" >
                    <option class="choose" value="0">choose</option>
                    <option class="choose" value="150">termite</option>
                    <option class="choose" value="550">rat</option>
                </select>
            </div>
            <div class="col-xs-12 input-group">
                <input id="area" class="form-control" type="text" value="" placeholder="floor area">
                <span class="input-group-addon">m&sup2;</span>
            </div>
            <div class="col-xs-12">
                <button id="calculate" class="btn btn-default form-control">calculate</button>
            </div>
            <div class="col-xs-12 input-group">
                <span class="input-group-addon">&#8369;</span>
                <input id="quote" class="form-control" type="text" placeholder="total" value="" disabled>
                <span class="input-group-addon">.00</span>
            </div>
        </div>
    </div>
    <script src="http://code.jquery.com/jquery.js"></script>
    <script type="text/javascript" src="quote.js"></script>
</body>
</html>