5

i got a css rule like this:

#imgwrapper {display: block;position: relative;width:auto;height:auto;}

so i got a hyperlink that when it's clicked, it should add a css rule to #imgwrapper like this:

#imgtarget, #imgwrapper img {cursor:crosshair;}

how should i do it??

i tried jquery .css() api but it aint working..

chrizonline
  • 4,779
  • 17
  • 62
  • 102

2 Answers2

9

See the $.css() function

$('a.whatever').click(function() {
  $('#imgtarget').css('cursor' , 'crosshair');
  $('#imgwrapper img').css('cursor', 'crosshair');
});
David Fells
  • 6,678
  • 1
  • 22
  • 34
  • hey david, your solution works.. but now wat if i wanna remove these css properties?? – chrizonline May 01 '11 at 07:15
  • hey david, i found the solution. sorry my bad.. what i did is to set the value to ''.. so ie: $('#imgtarget').css('cursor' , ''); $('#imgwrapper img').css('cursor', ''); – chrizonline May 01 '11 at 07:17
2

the following code should work.

$('#imgwrapper').css('cursor','crosshair')
kobe
  • 15,671
  • 15
  • 64
  • 91