Jacob Clark
Jacob Clark

Reputation: 3447

TypeError: Object #<HTMLDivElement> has no method 'css' w/ Express.js

Attempting to change the CSS of a div element in jQuery via Chrome Console and getting this response:

$('#first-block').css('color','green')
TypeError: Object #<HTMLDivElement> has no method 'css'

However when I call

$('#first-block')

The console returns the div and it's contents

I'm using Express.js w/ MongoDB, utilising the Express cache middleware.

Upvotes: 1

Views: 1854

Answers (1)

Jacob T Waverley
Jacob T Waverley

Reputation: 34

It seems like you're not loading jQuery correctly. Make sure that you've loaded jQuery in your haed section, and that your code in wrapped in the appropriate way, e.g.

<script type="text/javascript">
    jQuery(document).ready(function ($) {
        $('#first-block').css('color','green');
    });
</script>

Upvotes: 1

Related Questions