Home >Web Front-end >HTML Tutorial >Remove the expression Expression_html/css_WEB-ITnose in CSS

Remove the expression Expression_html/css_WEB-ITnose in CSS

WBOY
WBOYOriginal
2016-06-24 11:55:541102browse

In IE, CSS can embed js expressions and can be defined in CSS classes. However, if the CSS class containing the expression is removed from the DOM object, the style expression will not be invalid. .

After research, I found the answer. You need to use js to call the removeExpression() method of the style object to remove it.

The following is a description of the method:

Syntax

bSuccess = object<strong>.removeExpression(</strong>sPropertyName<strong>)</strong>

Parameters

table> Returns one of the following possible values: Switch between actual size and zoomed size with one button.

sPropertyName Required.
sPropertyName Required. String that specifies the name of the property from which to remove an expression.
String

that specifies the name of the property from which to remove an expression.

true The expression was successfully removed.
false The expression was not removed.
CSS class, function: limit the maximum width of the image, and shrink it proportionally beyond the specified width.

Css code

.wrap {

border:none;
    max-width:730px ;
  1. height:auto;
  2. width:expression(this.width>730?"730px":true);/*ie6 patch*/
  3. }
  4. Imagea1f02c36ba31691bcfe87b2722de723b

Html code

5cc63059df99461c78494128a2931fba

  1. Toggle Button

Html code

a4af2b3a872e6e2bb0e73efc1711532a[original size]d6d448110e0324953b5d7bc1e2b276ce

  1. js code (requires jQuery)

Java code

function showOrigin(){

$('#chart_img').toggleClass("chart");
  1. if($('#chart_img'). attr("class")){
  2. $('#imgctr').text("[original size]");
  3. }else{
  4. $(' #imgctr').text("[zoom size]");
  5. $('#chart_img')[0].style.removeExpression('width'); /*ie6 patch*/
  6.  
  7. }
  8. This example can only reflect the function of removeExpression() in IE6, ie7 The above is not required.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn