English 中文(简体)
1. 采用javascript的先前声明的确定风格价值
原标题:Resetting style values to previous declaration using javascript

审议以下事项:

<style type = text/css >
   .c1
   {
        opacity:0.3;
   }
</style>

以及

<div class =  c1  id =  myDiv ></div>

以及

<script>
   function cssFn()
   {
       document.getElementById( myDiv ).style.opacity = 0.8;
   }
   cssFn();

</script>

Thus i changed the opacity of the element using javascript.. My question is this.Is it possible to make the style declaration done using javascript to be inactive 以及 that declared in class to be active using javascript..I dont need

document.getElementById( myDiv ).style.opacity = 0.3;

我只需要一部与使用风格表格宣布的风格相仿的法典。

问题回答

我不知道这是否能够轻易做到。 改变javascript的风格,就以下要素形成一条行文风格:<div作则=“opacity:0.3;“>, 您可删除其属性或可删除 import! 然而,这两种解决办法都是 ha。

或者正如在另一个问题上所建议的那样,你可以将财产设定为“......”,这将否定规则,采用风格规则。

你们可以尝试使用2种不同的课程。

<style type="text/css">
  .c1 {
   opacity: 0.3;
  }
  .c2 {
   opacity: 0.8;
  }
</style>

你们可以做javascript:

 document.getElementByID("myDiv").className = "c1";

Or with jQuery :

$("#myDiv").addClass("c1");

如果你需要的话,用Javascript或j Query添加/删除这一类。

因此,按照安德烈沙瓦开始的同样思路:

<style type = text/css >
   .c1
   {
     opacity:0.3;
   }
   .c2
   {
     opacity:0.3;
   }
</style>

在你的职责中,利用 j子,而不是通过特性人工改变不透明:

$("myDiv").addClass("c2");

然后,用 j子,用 j子做你的工作。 逻辑:

$("#myDiv").removeClass("c2");




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!