0

I am getting error "object does not support property or method" on IE 8 with jquery 1.8 on the following

jQuery(".errorContents");

I am using DWR along with jQuery in my project and also added $.noConflict(); but keep getting the above mentioned error

function addError(){
       var errorContents= jQuery(".errorContents");
       errorContents.html('Errors in the Page');
       errorContents.show(); 
}
Prince Charming
  • 401
  • 4
  • 19
  • 1
    `jQuery(".errorContents");` is only a selector. What do you want to achieve? – Dygestor Feb 19 '13 at 10:23
  • @Dygestor I want to write some messages "String text" in the 'errorContents' Div in document but it throws "object does not support property or method" error on jQuery(".errorContents"); – Prince Charming Feb 19 '13 at 10:26
  • 1
    well if `jQuery(".errorContents");` is all you've got, then it probably will throw such error, as that code does nothing useful.. Could you post an example of such page? – Dygestor Feb 19 '13 at 10:28
  • @Dygestor I have added the function where I am getting this error – Prince Charming Feb 19 '13 at 10:41
  • did you try removing that variable and simply use `jQuery(".errorContents").html('Errors in the Page');`? – Dygestor Feb 19 '13 at 10:53

2 Answers2

0

This works fine for me:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
</head>
<body>
<div class="errorContents">asdf</div>
<script type="text/javascript">
    function addError() {
        var errorContents = $(".errorContents");
        errorContents.html('Errors in the Page');
        errorContents.show();
    }
    addError();
</script>
</body>
</html>

Fiddle: http://jsfiddle.net/5wbb8/

Sam Shiles
  • 10,529
  • 9
  • 60
  • 72
0

This might be because of multiple loading of same jQuery plugin or loading multiple versions of jQuery plugin.

Aditya Singh
  • 9,512
  • 5
  • 32
  • 55