0

I have wrote code like that:

    <style>
        *{margin: 0 ; padding: 0;}
        html,body{height:100%}
        div#rect {background: #39c; width:100% ; height:100% ; clip: rect(200px 700px 400px 500px);position: fixed;}
    </style>

   <div id="rect"></div>

How can I get the property 'clip' and change it with javascript?

Just like $('#rect').css( 'clip', '...' ) with jQuery.

It can not be change by element.style.clipRight = '' or element.style.clip = ''.

Chard
  • 11
  • 3
  • Are you saying it works with jQuery but you can't set it directly? That seems a bit odd given that jQuery's `.css()` method just does `element.style.clip = ` internally. (Or `element.style["clip"] =`, but it's the same thing.) – nnnnnn Mar 19 '13 at 03:25
  • Seems to work just fine for me -> [**FIDDLE**](http://jsfiddle.net/t6awK/1/) – adeneo Mar 19 '13 at 03:30
  • So that's my question.Why jQuery can make it, but with element.style.clip = Or element.style["clip"] I can not make it. – Chard Mar 19 '13 at 03:45
  • To expand on @adeneo's fiddle, it works with `.style.clip` - note the position changes after the alert closes: http://jsfiddle.net/t6awK/2/ – nnnnnn Mar 19 '13 at 04:28
  • I've made a mistake.It is solved.Thanks all. – Chard Mar 19 '13 at 04:28

1 Answers1

2

document.getElementById("rect").style.clip

deepak
  • 199
  • 2
  • 9