Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I'm trying to set a style on a div element using JQuery but receive an error - this is a snippet of the code
var HourControl = $('#hour'); -- this is a div element
 // I get intellisense for setStyle
 HourControl.setStyle("-webkit-transform: rotate("90deg")");


// Throws this error
Object doesn't support property or method 'setStyle'
Does this error refer to setStyle or -webkit-transform ?

What I have tried:

Google and this code
var HourControl = $('#hour'); -- this is a div element
 // I get intellisense for setStyle
 HourControl.setStyle("-webkit-transform: rotate("90deg")");
Posted
Updated 8-Sep-21 5:26am

1 solution

setStyle is not a jQuery method:
jQuery API Documentation[^]

I suspect you're looking for the css method:
.css() | jQuery API Documentation[^]
JavaScript
$('#hour').css('-webkit-transform', 'rotate("90deg")');
 
Share this answer
 
Comments
pkfox 8-Sep-21 12:46pm    
Thanks Richard

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900