1

I'd like to add into a css property like this

[css]

.someclass some
{ 
///
}

[jquery]

$('.someclass some').css('behavior','url(path/something/someclass.htc)');

This return an error message as "TypeError:Object Expected"

5
  • You need to check your selector as it may not be returning the object. Commented Nov 20, 2012 at 5:04
  • post the html of element on which you want to apply this css Commented Nov 20, 2012 at 5:05
  • sometimes when you include jquery twice in the page you get this kind of a error. check whether you have mistakenly done that("TypeError:Object Expected") Commented Nov 20, 2012 at 5:06
  • Are you saying you want to use jQuery to change the style settings associated with a particular class in your stylesheet, such that both elements that already have that class and elements that are later given that class will automatically pick up the new styles? Commented Nov 20, 2012 at 5:16
  • Yes, a styled element can be modified at load/runtime Commented Nov 20, 2012 at 5:26

2 Answers 2

1

Add a class to your CSS file, then toggle it in your JavaScript.

Sign up to request clarification or add additional context in comments.

Comments

0

try this:

 $('.someclass some').css({'behavior' : 'path/something/someclass.htc' });

just copying your code for behavior property - you know it should look like this....

 $('.someclass some').css({'behavior' : 'url (path/something/someclass.htc)' });

This code will add the css property to the selector in your DOM , if you want to actually change the css file - you can not do that , but you can do this

 $('.yourClass').addClass('behavior');

the class .behavior you put in your css - this will have extra properties , and you dynamically add this class to the elements that you want to have it

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.